Exemplo n.º 1
0
        public JsonResult DeleteDutyReason(DutyReason dutyReason)
        {
            var          isSuccess = true;
            var          message   = string.Empty;
            const string url       = "/DutyReason/Index";

            permission = (RoleSubModuleItem)cacheProvider.Get(cacheKey) ?? roleSubModuleItemService.GetRoleSubModuleItemBySubModuleIdandRole(url,
                                                                                                                                             Helpers.UserSession.GetUserFromSession().RoleId);

            if (permission.DeleteOperation == true)
            {
                isSuccess = this.dutyReasonService.DeleteDutyReason(dutyReason.Id);
                if (isSuccess)
                {
                    message = Resources.ResourceDutyReason.MsgDutyReasonDeleteSuccessful;
                }
                else
                {
                    message = Resources.ResourceDutyReason.MsgDutyReasonDeleteFailed;
                }
            }
            else
            {
                message = Resources.ResourceCommon.MsgNoPermissionToDelete;
            }


            return(Json(new
            {
                isSuccess = isSuccess,
                message = message
            }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
        private static DutyReasonModel PrepareDutyReasonModel(DutyReason dutyReason)
        {
            DutyReasonModel dutyReasonTemp = new DutyReasonModel();

            dutyReasonTemp.Id   = dutyReason.Id;
            dutyReasonTemp.Name = dutyReason.Name;
            if (dutyReason.IsActive != null)
            {
                dutyReasonTemp.IsActive = dutyReason.IsActive.Value;
            }
            return(dutyReasonTemp);
        }
Exemplo n.º 3
0
        public bool UpdateDutyReason(DutyReason dutyReason)
        {
            bool isSuccess = true;

            try
            {
                dutyReasonRepository.Update(dutyReason);
                this.SaveRecord();
                ServiceUtil <DutyReason> .WriteActionLog(dutyReason.Id, ENUMOperation.UPDATE, dutyReason);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in updating DutyReason", ex);
            }
            return(isSuccess);
        }
Exemplo n.º 4
0
 public bool CheckIsExist(DutyReason dutyReason)
 {
     return(dutyReasonRepository.Get(chk => chk.Name == dutyReason.Name) == null ? false : true);
 }
Exemplo n.º 5
0
        public JsonResult CreateDutyReason(DutyReason dutyReason)
        {
            var          isSuccess = false;
            var          message   = string.Empty;
            var          isNew     = dutyReason.Id == 0 ? true : false;
            const string url       = "/DutyReason/Index";

            permission = (RoleSubModuleItem)cacheProvider.Get(cacheKey) ??
                         roleSubModuleItemService.GetRoleSubModuleItemBySubModuleIdandRole(url, Helpers.UserSession.GetUserFromSession().RoleId);

            if (isNew)
            {
                if (permission.CreateOperation == true)
                {
                    if (!CheckIsExist(dutyReason))
                    {
                        if (this.dutyReasonService.CreateDutyReason(dutyReason))
                        {
                            isSuccess = true;
                            message   = Resources.ResourceDutyReason.MsgDutyReasonSaveSuccessful;
                        }
                        else
                        {
                            message = Resources.ResourceDutyReason.MsgDutyReasonSaveFailed;
                        }
                    }
                    else
                    {
                        isSuccess = false;
                        message   = Resources.ResourceDutyReason.MsgDuplicateDutyReason;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToCreate;
                }
            }
            else
            {
                if (permission.UpdateOperation == true)
                {
                    if (this.dutyReasonService.UpdateDutyReason(dutyReason))
                    {
                        isSuccess = true;
                        message   = Resources.ResourceDutyReason.MsgDutyReasonUpdateSuccessful;
                    }
                    else
                    {
                        message = Resources.ResourceDutyReason.MsgDutyReasonUpdateFailed;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToUpdate;
                }
            }

            return(Json(new
            {
                isSuccess = isSuccess,
                message = message,
            }, JsonRequestBehavior.AllowGet));
        }