public EditOrAddAwardWindowVM(ICollectionsEntity collectionEntity, AwardVM award = null) { _collectionEntity = collectionEntity; _award = award; ImageClearButtonVisibility = Visibility.Collapsed; if (_award != null) { if (_award.PerformerId != null) { Performer = new PerformerVM(DataLayer.Performer.GetById((Guid)_award.PerformerId)); } if (_award.EntertainmentId != null) { Entertainment = new EntertainmentVM(DataLayer.Entertainment.GetById((Guid)_award.EntertainmentId)); } Name = _award.Name; Nomination = _award.Nomination; Date = _award.Date; if (_award.Image != null) { ImageClearButtonVisibility = Visibility.Visible; } } NameErrorVisibility = Visibility.Hidden; DateErrorVisibility = Visibility.Hidden; Logger.Info("EditOrAddAwardWindowVM.EditOrAddAwardWindowVM", "Екземпляр EditOrAddAwardWindowVM створений."); }
public EditOrAddAwardWindow(ICollectionsEntity entity, AwardVM award = null) { InitializeComponent(); DataContext = new EditOrAddAwardWindowVM(entity, award); Logger.Info("EditOrAddAwardWindow.EditOrAddAwardWindow", "Екземпляр EditOrAddAwardWindow створений."); }
public void Add(object item) { AwardVM newItem = item as AwardVM; if (newItem != null) { _awardCollection.Add(newItem); } }
public ActionResult UpdateAward(AwardVM award) { if (ModelState.IsValid) { var updatedAward = new Award() { AwardID = award.AwardID, Description = award.Description, Title = award.Title }; Services.AwardService.UpdateAward(updatedAward); return(Json("ok")); } ModelState.AddModelError("", "One or more fields are invalid."); return(Redirect(Request.UrlReferrer.AbsolutePath)); }
public ActionResult AddAward(AwardVM award) { if (ModelState.IsValid) { if (Session.CurrentUser != null) { var userID = Session.CurrentUser.UserID; var user = Services.UserService.GetUserById(userID); var newAward = new Award() { Title = award.Title, Description = award.Description, CreationDate = System.DateTime.Now, UserID = userID }; Services.AwardService.AddAward(newAward, user); return(Json("ok")); } ModelState.AddModelError("", "Title field is required."); } return(Json("nok")); }
internal bool OkButtonClick() { _isError = false; if (Name == null || Name == String.Empty) { NameErrorVisibility = Visibility.Visible; _isError = true; } else { NameErrorVisibility = Visibility.Hidden; } if (Date == null) { DateErrorVisibility = Visibility.Visible; _isError = true; } else { DateErrorVisibility = Visibility.Hidden; } if (_isError) { return(false); } if (_award == null) { AwardVM award = new AwardVM(Performer == null ? null : Performer, Entertainment == null ? null : Entertainment, Name, Nomination, (DateTime)Date, Image == null ? null : File.ReadAllBytes(Image)); award.AwardDL.Save(); _collectionEntity.Add(award); } else { if (Performer != null) { _award.PerformerId = Performer.PerformerDL.Id; } else { _award.PerformerId = null; } if (Entertainment != null) { _award.EntertainmentId = Entertainment.EntertainmentDL.Id; } else { _award.EntertainmentId = null; } _award.Name = Name; _award.Nomination = Nomination; _award.Date = (DateTime)Date; if (Image != null && Image != String.Empty) { _award.Image = File.ReadAllBytes(Image); } else if (_clearImage) { _award.Image = null; } _award.AwardDL.Save(); } return(true); }