예제 #1
0
        public ActionResult Edit(HrPositionVM model)
        {
            if (ModelState.IsValid)
            {
                var position = _hrPositionService.GetByID(model.Id);
                if (position == null)
                {
                    return(RedirectToAction("Index"));
                }

                //do not update all fields with MapFrom method - will override created fields in database
                position.Code_1C = model.Code_1C;
                position.TitleEn = model.TitleEn;
                position.TitleRu = model.TitleRu;
                position.TitleUz = model.TitleUz;

                position.ModifiedAt = DateTime.Now;
                //TODO: add logic for WHO modified

                _hrPositionService.Update(position);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }
예제 #2
0
 public HrPosition MapFrom(HrPositionVM model)
 {
     return(new HrPosition
     {
         Id = model.Id,
         Code_1C = model.Code_1C,
         TitleRu = model.TitleRu,
         TitleEn = model.TitleEn,
         TitleUz = model.TitleUz
     });
 }
예제 #3
0
        public ActionResult Create(HrPositionVM model)
        {
            if (ModelState.IsValid)
            {
                var position = MapFrom(model);
                position.CreatedAt = DateTime.Now;
                //TODO: add logic for WHO created
                _hrPositionService.Create(position);
                return(RedirectToAction("Index"));
            }

            return(View(model));
        }