Example #1
0
        public ActionResult Edit(int?Id)
        {
            var Shifts = ShiftsRepository.GetShiftsById(Id.Value);

            if (Shifts != null && Shifts.IsDeleted != true)
            {
                var model = new ShiftsViewModel();
                AutoMapper.Mapper.Map(Shifts, model);

                //if (model.CreatedUserId != Erp.BackOffice.Helpers.Common.CurrentUser.Id && Erp.BackOffice.Helpers.Common.CurrentUser.UserTypeId != 1)
                //{
                //    TempData["FailedMessage"] = "NotOwner";
                //    return RedirectToAction("Index");
                //}

                return(View(model));
            }
            if (Request.UrlReferrer != null)
            {
                return(Redirect(Request.UrlReferrer.AbsoluteUri));
            }
            return(RedirectToAction("Index"));
        }
Example #2
0
 public ActionResult Create(WorkSchedulesViewModel model)
 {
     if (ModelState.IsValid)
     {
         var timekeeping = new Domain.Staff.Entities.WorkSchedules();
         var shift       = shiftsRepository.GetShiftsById(model.ShiftsId.Value);
         AutoMapper.Mapper.Map(model, timekeeping);
         timekeeping.IsDeleted      = false;
         timekeeping.CreatedUserId  = WebSecurity.CurrentUserId;
         timekeeping.ModifiedUserId = WebSecurity.CurrentUserId;
         timekeeping.CreatedDate    = DateTime.Now;
         timekeeping.ModifiedDate   = DateTime.Now;
         timekeeping.Day            = model.Day;
         timekeeping.ShiftsId       = model.ShiftsId;
         if (timekeeping.HoursIn > timekeeping.HoursOut)
         {
             timekeeping.HoursOut = timekeeping.HoursOut.Value.AddDays(1);
         }
         var      service_schedule = Request["group_choice"];
         string[] list             = service_schedule.Split(',');
         for (int i = 0; i < list.Count(); i++)
         {
             if (list[i] != "")
             {
                 timekeeping.Symbol = int.Parse(list[i], CultureInfo.InvariantCulture);
             }
         }
         timekeeping.ShiftsId = model.ShiftsId;
         var symbol = symboltimekeepingRepository.GetSymbolTimekeepingById(timekeeping.Symbol.Value);
         if (symbol.Absent == true)
         {
             timekeeping.Total_minute_work          = 0;
             timekeeping.Total_minute_work_early    = 0;
             timekeeping.Total_minute_work_late     = 0;
             timekeeping.Total_minute_work_overtime = 0;
         }
         else
         {
             timekeeping.HoursIn  = model.HoursIn;
             timekeeping.HoursOut = model.HoursOut;
         }
         workSchedulesRepository.InsertWorkSchedules(timekeeping);
         if (symbol.Absent == true)
         {
             var q = workSchedulesRepository.GetvwWorkSchedulesById(timekeeping.Id);
             //hàm tính dữ liệu chấm công.
             Erp.BackOffice.Staff.Controllers.TimekeepingController.KiemTraVaTinhDuLieuChamCong(q, timekeeping, model.HoursIn, model.HoursOut);
         }
         TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
         if (Request["IsPopup"] == "true" || Request["IsPopup"] == "True")
         {
             return(RedirectToAction("_ClosePopup", "Home", new { area = "", FunctionCallback = "ClosePopupAndReloadPage" }));
         }
         else
         {
             TempData[Globals.SuccessMessageKey] = App_GlobalResources.Wording.InsertSuccess;
             return(RedirectToAction("Index"));
         }
     }
     return(RedirectToAction("Create"));
 }