Beispiel #1
0
        public void Delete(DepartmentEmployeeViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
Beispiel #2
0
 public ActionResult Delete(DepartmentEmployeeViewModel model)
 {
     try
     {
         service.Delete(model);
         service.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public IActionResult DepartmentEmployee()
        {
            var model = new DepartmentEmployeeViewModel();

            model.Departments = _departmentRepository
                                .GetAll()
                                .Select(c => new SelectListItem
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            return(View(model));
        }
Beispiel #4
0
        public ActionResult Edit(DepartmentEmployeeViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Update(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
Beispiel #5
0
        public void Update(DepartmentEmployeeViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <DepartmentEmployeeViewModel, DepartmentEmployee>(model);

            _repository.Update(contractType);
        }
Beispiel #6
0
        public void Insert(DepartmentEmployeeViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <DepartmentEmployeeViewModel, DepartmentEmployee>(model);

            _repository.Add(contractType);
        }