Example #1
0
        public Att_LeaveDayModel GetById(Guid id)
        {
            string status = string.Empty;
            var model = new Att_LeaveDayModel();
            ActionService service = new ActionService(UserLogin);
            var entity = service.GetByIdUseStore<Att_LeaveDayEntity>(id, ConstantSql.hrm_att_sp_get_LeaveDayById, ref status);
            if (entity != null)
            {
                model = entity.CopyData<Att_LeaveDayModel>();
                if (model.LeaveHours != null && model.LeaveHours > 0)
                {
                    if (model.DurationType == LeaveDayDurationType.E_FIRSTHALFSHIFT.ToString() || model.DurationType == LeaveDayDurationType.E_LASTHALFSHIFT.ToString())
                    {
                        var guiId = model.ProfileID;
                        var start = model.DateStart;
                        var end = model.DateEnd;
                        if (guiId != null && guiId != Guid.Empty && start != null && end != null)
                        {
                            var listRoster = service.GetData<Att_RosterEntity>(guiId, ConstantSql.hrm_att_sp_get_RosterByProfileId, ref status);
                            if (listRoster != null)
                            {
                                for (DateTime i = start; i <= end; i = i.AddDays(1))
                                {
                                    var roster = listRoster.Where(d => d.DateStart <= i && d.DateEnd >= i).FirstOrDefault();
                                    if (roster != null)
                                    {
                                        var shift = SearchShift(roster, i);
                                        if (shift != null && shift != Guid.Empty)
                                        {
                                            var catShift = service.GetByIdUseStore<Cat_ShiftEntity>((Guid)shift, ConstantSql.hrm_cat_sp_get_ShiftById, ref status);
                                            if (catShift != null)
                                            {
                                                if (model.DurationType == LeaveDayDurationType.E_FIRSTHALFSHIFT.ToString())
                                                {
                                                    model.HoursFrom = catShift.InTime;
                                                    model.HoursTo = catShift.InTime.AddHours(catShift.CoBreakOut);
                                                    break;
                                                }
                                                else
                                                {
                                                    model.HoursFrom = catShift.InTime.AddHours(catShift.CoBreakIn);
                                                    model.HoursTo = catShift.InTime.AddHours(catShift.CoOut);
                                                    break;
                                                }
                                            }
                                        }

                                    }
                                }
                            }
                        }
                    }
                }
            }
            model.ActionStatus = status;
            return model;

        }
        public ActionResult Create(Att_LeaveDayModel model)
        {

            if (ModelState.IsValid)
            {
                var service = new RestServiceClient<Att_LeaveDayModel>(UserLogin);
                service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
                var result = service.Put(_Hrm_Hre_Service, "api/Att_Leaveday/", model);
                ViewBag.MsgInsert = ConstantDisplay.HRM_Attendance_LeaveDay_InsertSuccess.TranslateString();
            }
            return View();
        }
Example #3
0
 public ActionResult Edit(Guid id)
 {
     if (!CheckPermission()) return RedirectToAction("Denied", "Portal");
     string status = string.Empty;
     var model = new Att_LeaveDayModel();
     ActionService service = new ActionService(UserLogin);
     var entity = service.GetByIdUseStore<Att_LeaveDayEntity>(id, ConstantSql.hrm_att_sp_get_LeaveDayById, ref status);
     if (entity != null)
     {
         model = entity.CopyData<Att_LeaveDayModel>();
     } 
     model.ActionStatus = status;
     return GetOnlyView(model);
 }
Example #4
0
 public string Save(Att_LeaveDayModel model)
 {
     if (IdLeaveday != Guid.Empty)
     {
         model.ID = IdLeaveday;
     }
     if (model.DurationType =="E_FULLSHIFT" )
     {
         model.LeaveHours = 8;
     }
     ActionService service = new ActionService(UserLogin);
     service.UpdateOrCreate<Att_LeaveDayEntity, Att_LeaveDayModel>(model);
     //IdLeaveday = model.ID;
     //if (model.ID != Guid.Empty)
     //{
     //    return model.ID.ToString();
     //}
     return model.ActionStatus;
 }
 public ActionResult Edit([DataSourceRequest] DataSourceRequest request, Att_LeaveDayModel AttLeaveday)
 {
     if (ModelState.IsValid)
     {
         var service = new RestServiceClient<Att_LeaveDayModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
         var result = service.Put(_Hrm_Hre_Service, "api/Att_Leaveday/", AttLeaveday);
         ViewBag.MsgUpdate = ConstantDisplay.HRM_Attendance_LeaveDay_UpdateSuccess.TranslateString();
     }
     return View();
 }
 /// <summary>
 /// Cập nhật tổng số ngày nghĩ
 /// </summary>
 /// <param name="selectedIds"></param>
 /// <returns></returns>
 public ActionResult UpdateSumLeaveday(List<Guid> selectedIds)
 {
     var leaveDay = new Att_LeaveDayModel();
     if (selectedIds != null && selectedIds.Count>0)
     {
         leaveDay.lstLeaveIDs = selectedIds;
         var service = new RestServiceClient<Att_LeaveDayModel>(UserLogin);
         service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
         leaveDay = service.Post(_Hrm_Hre_Service, "api/Att_LeavedayCustom/", leaveDay);
     }
     return Json(leaveDay);
 }
        /// <summary>
        /// Xử lí thay doi trang thai cua Att_Leaveday
        /// </summary>
        /// <param name="contract"></param>
        /// <returns></returns>      
        public ActionResult SetStatusSelected(List<Guid> selectedIds, string status, string userApproved)
        {
            var model = new Att_LeaveDayModel();
            if (selectedIds != null || selectedIds.Count>0)
            {

                var service = new RestServiceClient<Att_LeaveDayModel>(UserLogin);
                service.SetCookies(this.Request.Cookies, _Hrm_Hre_Service);
                model.ProfileIds = String.Join(",", selectedIds);
                model.Status = status;
                Guid Approved = Guid.Empty;
                Guid.TryParse(userApproved, out Approved);
                if (Approved == Guid.Empty)
                {
                    model.ActionStatus = "NoPermission";
                    return Json(model);
                }
                model.UserApproveID = Approved;
                model.UserApproveID2 = Approved;
                model = service.Put(_Hrm_Hre_Service, "api/Att_Leaveday/", model);
            }
            return Json(model);
        }
Example #8
0
 public ActionResult Create(Att_LeaveDayModel model)
 {
     var service = new RestServiceClient<Att_LeaveDayModel>(UserLogin);
     service.SetCookies(this.Request.Cookies, _hrm_Hr_Service);
     var result = service.Post(_hrm_Hr_Service, "api/Att_Leaveday/", model);
     return Json(result);
 }