Created
April 30, 2015 21:53
-
-
Save fpopic/7b9f6aae3fcd0987874c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using System.ComponentModel; | |
| using System.Text; | |
| namespace Model | |
| { | |
| public partial class Boat : IDataErrorInfo | |
| { | |
| public override string ToString() | |
| { | |
| return BoatName; | |
| } | |
| #region IDataErrorInfo Members | |
| public string Error | |
| { | |
| get | |
| { | |
| var sb = new StringBuilder(); | |
| if (!string.IsNullOrWhiteSpace(this["BoatName"])) { | |
| sb.AppendLine(this["BoatName"]); | |
| } | |
| if (!string.IsNullOrWhiteSpace(this["Lenght"])) { | |
| sb.AppendLine(this["Lenght"]); | |
| } | |
| if (!string.IsNullOrWhiteSpace(this["OwnerId"])) { | |
| sb.AppendLine(this["OwnerId"]); | |
| } | |
| if (!string.IsNullOrWhiteSpace(this["BoatTypeId"])) { | |
| sb.AppendLine(this["BoatTypeId"]); | |
| } | |
| if (!string.IsNullOrWhiteSpace(this["CountryId"])) { | |
| sb.AppendLine(this["CountryId"]); | |
| } | |
| // Check foreach boatEmployee's attributes | |
| foreach (var be in BoatEmployees) { | |
| if (!string.IsNullOrWhiteSpace(be.Error)) { | |
| sb.Append(be.Error); | |
| } | |
| } | |
| return sb.Length > 0 ? sb.ToString() : String.Empty; | |
| } | |
| } | |
| public string this[string columnName] | |
| { | |
| get | |
| { | |
| switch (columnName) { | |
| case "BoatName": | |
| return !string.IsNullOrWhiteSpace(BoatName) ? "Naziv plovila nije unesen!" : String.Empty; | |
| case "Lenght": | |
| return Length == 0 ? "Duljina plovila nije unesena!" : String.Empty; | |
| case "OwnerId": | |
| return OwnerId == 0 ? "Vlasnik plovila nije unesen!" : String.Empty; | |
| case "BoatTypeId": | |
| return BoatTypeId == 0 ? "Tip plovila nije unesen!" : String.Empty; | |
| case "CountryId": | |
| return CountryId == 0 ? "Drzava registracije plovila nije unesena!" : String.Empty; | |
| default: | |
| return String.Empty; | |
| } | |
| } | |
| } | |
| #endregion | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment