Exemplo n.º 1
0
        /// <summary>
        /// Validate request
        /// </summary>
        /// <param name="request"></param>
        /// <param name="response"></param>
        public PoliScheduleResponse Validate(PoliScheduleRequest request)
        {
            var response = new PoliScheduleResponse();

            if (request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString()))
            {
                response = ValidateForDelete(request);
            }
            else
            {
                bool isHavePrivilege = true;

                if (request.Data.Id == 0)
                {
                    isHavePrivilege = IsHaveAuthorization(ADD_PRIVILEGE_NAME, request.Data.Account.Privileges.PrivilegeIDs);
                }
                else
                {
                    isHavePrivilege = IsHaveAuthorization(EDIT_PRIVILEGE_NAME, request.Data.Account.Privileges.PrivilegeIDs);
                }

                if (!isHavePrivilege)
                {
                    response.Status  = false;
                    response.Message = Messages.UnauthorizedAccess;
                }

                if (response.Status)
                {
                    response = new PoliScheduleHandler(_unitOfWork).CreateOrEdit(request);
                }
            }

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Delete validation
        /// </summary>
        /// <param name="request"></param>
        private PoliScheduleResponse ValidateForDelete(PoliScheduleRequest request)
        {
            var response = new PoliScheduleResponse();

            bool isHavePrivilege = IsHaveAuthorization(DELETE_PRIVILEGE_NAME, request.Data.Account.Privileges.PrivilegeIDs);

            if (!isHavePrivilege)
            {
                response.Status  = false;
                response.Message = Messages.UnauthorizedAccess;
            }

            if (response.Status)
            {
                response = new PoliScheduleHandler(_unitOfWork).RemoveData(request);
            }

            return(response);
        }