public static string Edit(RankDTO Rank) { using (ArmyBaseContext db = new ArmyBaseContext()) { string error = null; var toModify = db.Ranks.Where(x => x.Id == Rank.Id).FirstOrDefault(); toModify.Name = Rank.Name; toModify.Description = Rank.Description; toModify.MinExperience = Rank.MinExperience; toModify.CanLead = Rank.CanLead; toModify.Bonus = Rank.Bonus; var context = new ValidationContext(toModify, null, null); var result = new List <ValidationResult>(); Validator.TryValidateObject(toModify, context, result, true); foreach (var x in result) { error = error + x.ErrorMessage + "\n"; } if (error == null) { db.SaveChanges(); } return(error); } }
public static Rank ConvertRespondentInfoFromDTO(RankDTO rankDTO) { Mapper.CreateMap <RankDTO, Rank>().ConvertUsing( m => { return(new Rank { RankId = m.RankId, RankName = m.RankName, RankDescription = m.RankDescription, RankSalary = m.RankSalary, RankMaxGrade = m.RankMaxGrade, RankPerGradeAmount = m.RankPerGradeAmount, BankAllowance = m.BankAllowance, Incentive = m.Incentive, SiteInchargeship = m.SiteInchargeship, UniformAllowance = m.UniformAllowance, RankSpecialAllowance = m.RankSpecialAllowance, RankInchargeShipAllowance = m.RankInchargeShipAllowance, RankOtherAllowances = m.RankOtherAllowances, OverTimeRate = m.OverTimeRate, }); }); return(Mapper.Map <RankDTO, Rank>(rankDTO)); }
public void LoadModifyRankPage(RankDTO rank) { IWindowManager manager = new WindowManager(); AddRankViewModel add = new AddRankViewModel(rank); manager.ShowDialog(add, null, null); Reload(); }
public static void Delete(RankDTO Rank) { using (ArmyBaseContext db = new ArmyBaseContext()) { var toDelete = db.Ranks.Where(x => x.Id == Rank.Id).FirstOrDefault(); toDelete.IsDisabled = true; db.SaveChanges(); } }
public void CheckOutDay(RankDTO rankDto) { var data = db.Ranks.SingleOrDefault(x => x.ID == rankDto.ID); if (data != null) { data.RMusicEnd = rankDto.RMusicEnd; } db.SaveChanges(); }
internal RankDTO CreateDTO() { RankDTO dto = new RankDTO(); dto.Author = this.Author.Id; dto.Description = this.Description; dto.Time = this.Time; dto.Value = this.Value; return(dto); }
public AddRankViewModel(RankDTO rank) { IsEdit = true; ButtonLabel = "Edit"; this.toEdit = rank; Name = toEdit.Name; Description = toEdit.Description; Bonus = toEdit.Bonus; CanLead = toEdit.CanLead; MinExperience = toEdit.MinExperience; }
public void Delete(RankDTO rank) { IWindowManager manager = new WindowManager(); DeleteConfirmationViewModel modify = new DeleteConfirmationViewModel(); bool?showDialogResult = manager.ShowDialog(modify, null, null); if (showDialogResult != null && showDialogResult == true) { RankService.Delete(rank); } Reload(); }
public void UpdateRank(RankDTO rank) { new RankDao().Update(new Rank() { ID = rank.ID, RMusicName = rank.RMusicName, //RMusicStart = rank.RMusicStart, CateID = rank.CateID, //RMusicEnd = rank.RMusicEnd, SongOrMusic = rank.SongOrMusic }); }
public IHttpActionResult UpdateRank(int id, [FromBody] RankDTO rank) { try { new Repositories().UpdateNewRank(rank); return(Ok()); } catch (Exception e) { Console.WriteLine(e); return(NotFound()); } }
public ActionResult CreateRank(RankDTO rank) { ViewBag.ListOldRank = ApiService.GetAllLastWeekRank(); ViewBag.ListCategories = ApiService.GetAllCate(); if (!ModelState.IsValid) { return(View()); } if (ApiService.CreateNewRank(rank)) { return(RedirectToAction("ListRanks")); } return(View()); }
public ActionResult EditRank(RankDTO rank) { ViewBag.ListCategories = ApiService.GetAllCate(); var data = ApiService.GetAllRank().SingleOrDefault(x => x.ID == rank.ID); if (!ModelState.IsValid) { return(View(data)); } if (ApiService.UpdateRank(rank)) { return(RedirectToAction("ListRanks")); } return(View(data)); }
public async Task <ActionResult <RankDTO> > UpdateAsync([FromBody] RankDTO model) { try { return(Ok(await rankService.UpdateAsync(model))); } catch (NotFoundException e) { return(NotFound(new { Id = e.Key, e.Message })); } catch (ValidationException e) { return(BadRequest(e.ValidationErrors)); } }
public ActionResult RankCreate(RankDTO data) { try { _rankService.InsertRank(data); ViewBag.success = String.Format("New Rank Added"); ModelState.Clear(); return(View()); } catch (Exception Ex) { ViewBag.error = Ex.Message; TempData["Danger"] = Ex.Message; return(View()); } }
public void CreateNewRank(RankDTO rank) { new RankDao().Create(new Rank() { RMusicName = rank.RMusicName, RMusicStart = rank.RMusicStart, CateID = rank.CateID, RMusicEnd = rank.RMusicEnd, SongOrMusic = rank.SongOrMusic, OldWeekRankId = rank.OldWeekRankId }); if (rank.OldWeekRankId != 0) { var data = new RankBus().GetListRankThisWeek().SingleOrDefault(x => x.ID == rank.OldWeekRankId); if (data != null) { foreach (var music in data.MusicDtos) { new RankMusicDao().Create(new RankMusic() { MusicID = music.ID, RankID = data.ID, RMusicGrade = music.GradeRank }); } } new RankDao().CheckOutDay(new RankDTO() { ID = rank.OldWeekRankId, RMusicEnd = DateTime.Now }); } }
public RankDTO InsertRank(RankDTO data) { Rank rnk = RankRequestFormatter.ConvertRespondentInfoFromDTO(data); return(RankRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.RankRepository.Create(rnk))); }
internal static Rank FromDTO(RankDTO x) { throw new NotImplementedException(); }
public RedirectResult RankEdit(RankDTO data) { int rnk = _rankService.UpdateRank(data); return(Redirect("/rank/edit/" + data.RankId)); }
public void CreateNewRank(RankDTO rank) { new RankBus().CreateNewRank(rank); }
public void UpdateNewRank(RankDTO rank) { new RankBus().UpdateRank(rank); }
public RankDTO GetRankByID(int rankId) { RankDTO rank = RankRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.RankRepository.GetById(rankId)); return(rank); }
public ActionResult RankEdit(int rankId) { RankDTO rankbyId = _rankService.GetRankByID(rankId); return(View(rankbyId)); }
public int UpdateRank(RankDTO data) { Rank rnk = RankRequestFormatter.ConvertRespondentInfoFromDTO(data); return(_unitOfWork.RankRepository.Update(rnk)); }