99.02 DateTime and Currency formating issue. Validation. (Book) (Xamarin) - chempkovsky/CS2WPF-and-CS2XAMARIN GitHub Wiki
- Please take a close look at the slide below
- Book R page
- "Publication date"-column has a time suffix="12:00:00AM"
- "Completion date"-column is shown without time suffix.
Let's look at the CompletionDate-field of LitManuscript-entity
[Display(Description = "Date Of Manuscript Completion (not Required)", Name = "Completion Date", Prompt = "Enter Completion Date", ShortName = "Completion Date")]
[DataType(DataType.Date)]
[Required]
public DateTime CompletionDate { get; set; }
And let's look at the PublicationDate-field of LitBook-entity
[Display(Description = "Publication Date", Name = "Publication Date", Prompt = "Enter Publication Date", ShortName = "Publication Date")]
public DateTime PublicationDate { get; set; }
CompletionDate-field of LitManuscript-entity has additional attribure
[DataType(DataType.Date)]
It affects formatting!!!!!
- Please take a close look at the slide below
- Book R page
- "Price"-column has a Currency-prefix
And let's look at the Price-field of LitBook-entity
[Display(Description = "Book Price", Name = "Book Price", Prompt = "Enter Book Price", ShortName = "Book Price")]
[DataType(DataType.Currency)]
public Double Price { get; set; }
Price-field of LitBook-entity has additional attribure
[DataType(DataType.Currency)]
It affects formatting!!!!!
- Please navigate to Book R page
- Please navigate to "Add Item"-page for Book
- Please click "Submit"-button
- Please type any letter in "Title of the book"-control
android App
And let's look at the BookTitle-field of LitBook-entity
[Display(Description = "Title of the Literary Book", Name = "Title of the Literary Book", Prompt = "Enter the title of the Literary Book", ShortName = "Book Title")]
[Required]
[StringLength(55, MinimumLength = 3)]
public string BookTitle { get; set; }
We have [Required] and [StringLength] attributes
It affects validation!!!!!
- Open the file "Controllers\LitBookViewWebApiController.cs" of "Dm04WebApp"-project and Navigate to "addone"-method.
- This is a server side validation
[HttpPost]
[ResponseType(typeof(LitBookView))]
[Route("addone")]
public IHttpActionResult addone([FromBody] LitBookView viewToAdd)
{
if (!ModelState.IsValid)
{
return BadRequest(ModelState);
}
...
}
- Open the file "Literature\LitBook\ViewModels\LitBookViewEformViewModel.cs" of "ModelServicesPrismModule"-project and Navigate to the beginning of "LitBookViewEformViewModel"-class.
- This is a client side validation
namespace ModelServicesPrismModule.Literature.LitBook.ViewModels {
public class LitBookViewEformViewModel: INotifyPropertyChanged, INotifyDataErrorInfo, IEformViewModelInterface, IBindingContextChanged
{
It implements "INotifyDataErrorInfo"-interface. Xamarin 5 accepts it (We mean System.ComponentModel and all around it).