public ActionResult Edit(TimekeepingViewModel model)
        {
            //model.EmployeeId = model.Employee.Id;
            //model.DepartmentId = 1;
            //model.TimeAttendanceTypeId = model.TimeAttendanceType.Id;
            try
            {
                if (ModelState.IsValid)
                {
                    service.Update(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }
                var departments = _departmentService.GetDepartments();
                ViewBag.Departments = new SelectList(departments, "Id", "Name");

                var contens = new List <KeyValuePair <string, string> > {
                    new KeyValuePair <string, string>("BT", "Bình thường"),
                    new KeyValuePair <string, string>("TC", "Tăng ca")
                };
                ViewBag.Contens = new SelectList(contens, "Key", "Value");

                var timeAttendanceTypes = timeAttendanceType.GetTimeAttendanceTypes();
                ViewBag.TimeAttendanceTypes = new SelectList(timeAttendanceTypes, "Id", "Code");

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
        // GET: Timekeeping/Edit/5
        public ActionResult Edit(long id)
        {
            TimekeepingViewModel timekeepingViewModel = service.GetInfo(id);

            if (timekeepingViewModel == null)
            {
                return(RedirectToAction("Index", "Timekeeping"));
            }
            var departments = _departmentService.GetDepartments();

            ViewBag.Departments = new SelectList(departments, "Id", "Name");

            var contens = new List <KeyValuePair <string, string> > {
                new KeyValuePair <string, string>("BT", "Bình thường"),
                new KeyValuePair <string, string>("TC", "Tăng ca")
            };

            ViewBag.Contens = new SelectList(contens, "Key", "Value");
            var timeAttendanceTypes = timeAttendanceType.GetTimeAttendanceTypes();

            ViewBag.TimeAttendanceTypes = new SelectList(timeAttendanceTypes, "Id", "Code");

            var model = service.GetInfo(id);

            return(View(model));
        }
Esempio n. 3
0
        public void Delete(TimekeepingViewModel model)
        {
            var item = _repository.FindById(model.Id);

            if (item != null)
            {
                _repository.Delete(item);
            }
        }
        public ActionResult KiemTraChamCong(TimekeepingViewModel model)
        {
            var tontai = service.GetTimekeepings().Where(x => x.EmployeeId == model.EmployeeId && x.Date == model.Date);

            if (tontai != null && tontai.Any())
            {
                return(Json(new { daCham = true, chamCong = string.Join(", ", tontai.Select(c => c.TimeAttendanceType.Code)) }));
            }
            return(Json(new { daCham = false, chamCong = string.Empty }));
        }
 public ActionResult Delete(TimekeepingViewModel model)
 {
     try
     {
         service.Delete(model);
         service.Save();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View());
     }
 }
        public ActionResult Create(TimekeepingViewModel model)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    service.Insert(model);
                    service.Save();
                    return(RedirectToAction("Index"));
                }

                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
 public ActionResult Luu(TimekeepingViewModel model)
 {
     service.Insert(model);
     service.Save();
     return(Json(1));
 }
Esempio n. 8
0
        public void Update(TimekeepingViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <TimekeepingViewModel, Timekeeping>(model);

            _repository.Update(contractType);
        }
Esempio n. 9
0
        public void Insert(TimekeepingViewModel model)
        {
            var contractType = AutoMapper.Mapper.Map <TimekeepingViewModel, Timekeeping>(model);

            _repository.Add(contractType);
        }