예제 #1
0
        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);
            }
        }
예제 #2
0
 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));
 }
예제 #3
0
        public void LoadModifyRankPage(RankDTO rank)
        {
            IWindowManager   manager = new WindowManager();
            AddRankViewModel add     = new AddRankViewModel(rank);

            manager.ShowDialog(add, null, null);
            Reload();
        }
예제 #4
0
        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();
            }
        }
예제 #5
0
        public void CheckOutDay(RankDTO rankDto)
        {
            var data = db.Ranks.SingleOrDefault(x => x.ID == rankDto.ID);

            if (data != null)
            {
                data.RMusicEnd = rankDto.RMusicEnd;
            }
            db.SaveChanges();
        }
예제 #6
0
        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);
        }
예제 #7
0
        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;
        }
예제 #8
0
        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();
        }
예제 #9
0
 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
     });
 }
예제 #10
0
 public IHttpActionResult UpdateRank(int id, [FromBody] RankDTO rank)
 {
     try
     {
         new Repositories().UpdateNewRank(rank);
         return(Ok());
     }
     catch (Exception e)
     {
         Console.WriteLine(e);
         return(NotFound());
     }
 }
예제 #11
0
 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());
 }
예제 #12
0
        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));
        }
예제 #13
0
 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));
     }
 }
예제 #14
0
 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());
     }
 }
예제 #15
0
        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
                });
            }
        }
예제 #16
0
        public RankDTO InsertRank(RankDTO data)
        {
            Rank rnk = RankRequestFormatter.ConvertRespondentInfoFromDTO(data);

            return(RankRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.RankRepository.Create(rnk)));
        }
예제 #17
0
 internal static Rank FromDTO(RankDTO x)
 {
     throw new NotImplementedException();
 }
예제 #18
0
        public RedirectResult RankEdit(RankDTO data)
        {
            int rnk = _rankService.UpdateRank(data);

            return(Redirect("/rank/edit/" + data.RankId));
        }
예제 #19
0
 public void CreateNewRank(RankDTO rank)
 {
     new RankBus().CreateNewRank(rank);
 }
예제 #20
0
 public void UpdateNewRank(RankDTO rank)
 {
     new RankBus().UpdateRank(rank);
 }
예제 #21
0
        public RankDTO GetRankByID(int rankId)
        {
            RankDTO rank = RankRequestFormatter.ConvertRespondentInfoToDTO(_unitOfWork.RankRepository.GetById(rankId));

            return(rank);
        }
예제 #22
0
        public ActionResult RankEdit(int rankId)
        {
            RankDTO rankbyId = _rankService.GetRankByID(rankId);

            return(View(rankbyId));
        }
예제 #23
0
        public int UpdateRank(RankDTO data)
        {
            Rank rnk = RankRequestFormatter.ConvertRespondentInfoFromDTO(data);

            return(_unitOfWork.RankRepository.Update(rnk));
        }