Ejemplo n.º 1
0
        public JsonResult DeleteAccademicYear(AccademicYear accademicYear)
        {
            var          isSuccess = true;
            var          message   = string.Empty;
            const string url       = "/AccademicYear/Index";

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

            if (permission.DeleteOperation == true)
            {
                isSuccess = this.accademicYearService.DeleteAccademicYear(accademicYear.AccademicYear1);
                if (isSuccess)
                {
                    message = Resources.ResourceAccademicYear.MsgAccademicYearDeleteSuccessful;
                }
                else
                {
                    message = Resources.ResourceAccademicYear.MsgAccademicYearDeleteFailed;
                }
            }
            else
            {
                message = Resources.ResourceCommon.MsgNoPermissionToDelete;
            }


            return(Json(new
            {
                isSuccess = isSuccess,
                message = message
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        private static AccademicYearModel PrepareAccademicYearModel(AccademicYear accademicYear)
        {
            AccademicYearModel accademicYearTemp = new AccademicYearModel();

            accademicYearTemp.AccademicYear1 = accademicYear.AccademicYear1;
            accademicYearTemp.Weekend1       = accademicYear.Weekend1;
            accademicYearTemp.Weekend2       = accademicYear.Weekend2;
            return(accademicYearTemp);
        }
Ejemplo n.º 3
0
        public bool UpdateAccademicYear(AccademicYear accademicYear)
        {
            bool isSuccess = true;

            try
            {
                accademicYearRepository.Update(accademicYear);
                this.SaveRecord();
                ServiceUtil <AccademicYear> .WriteActionLog(accademicYear.AccademicYear1, ENUMOperation.UPDATE, accademicYear);
            }
            catch (Exception ex)
            {
                isSuccess = false;
                logger.Error("Error in updating AccademicYear", ex);
            }
            return(isSuccess);
        }
Ejemplo n.º 4
0
        public JsonResult CreateAccademicYear(AccademicYear accademicYear)
        {
            var          isSuccess        = false;
            var          message          = string.Empty;
            var          accademicYearObj = accademicYearService.GetAccademicYear(accademicYear.AccademicYear1);
            var          isNew            = accademicYearObj == null;
            const string url = "/AccademicYear/Index";

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

            if (isNew)
            {
                if (permission.CreateOperation == true)
                {
                    if (!CheckIsExist(accademicYear))
                    {
                        if (this.accademicYearService.CreateAccademicYear(accademicYear))
                        {
                            isSuccess = true;
                            message   = Resources.ResourceAccademicYear.MsgAccademicYearSaveSuccessful;
                        }
                        else
                        {
                            message = Resources.ResourceAccademicYear.MsgAccademicYearSaveFailed;
                        }
                    }
                    else
                    {
                        isSuccess = false;
                        message   = Resources.ResourceAccademicYear.MsgDuplicateAccademicYear;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToCreate;
                }
            }
            else
            {
                if (permission.UpdateOperation == true)
                {
                    accademicYearObj.AccademicYear1 = accademicYear.AccademicYear1;
                    accademicYearObj.Weekend1       = accademicYear.Weekend1;
                    accademicYearObj.Weekend2       = accademicYear.Weekend2;

                    if (this.accademicYearService.UpdateAccademicYear(accademicYearObj))
                    {
                        isSuccess = true;
                        message   = Resources.ResourceAccademicYear.MsgAccademicYearUpdateSuccessful;
                    }
                    else
                    {
                        message = Resources.ResourceAccademicYear.MsgAccademicYearUpdateFailed;
                    }
                }
                else
                {
                    message = Resources.ResourceCommon.MsgNoPermissionToUpdate;
                }
            }

            return(Json(new
            {
                isSuccess = isSuccess,
                message = message,
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 5
0
 public bool CheckIsExist(AccademicYear accademicYear)
 {
     return(accademicYearRepository.Get(chk => chk.AccademicYear1
                                        == accademicYear.AccademicYear1) == null ? false : true);
 }