/// <summary> /// Validate request /// </summary> /// <param name="request"></param> /// <param name="response"></param> public LoketResponse Validate(LoketRequest request) { var response = new LoketResponse(); if (request.Action != null) { if (request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) { response = ValidateForDelete(request); } else if (request.Action.Equals(ClinicEnums.Action.Process.ToString())) { response = ValidateForProcess(request); } else if (request.Action.Equals(ClinicEnums.Action.Hold.ToString())) { response = ValidateForHold(request); } else if (request.Action.Equals(ClinicEnums.Action.Finish.ToString())) { response = ValidateForFinish(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 LoketHandler(_unitOfWork).CreateOrEdit(request); } } return(response); }
/// <summary> /// Process validation /// </summary> /// <param name="request"></param> /// <returns></returns> private LoketResponse ValidateForProcess(LoketRequest request) { var response = new LoketResponse(); bool isHavePrivilege = IsHaveAuthorization(EDIT_PRIVILEGE_NAME, request.Data.Account.Privileges.PrivilegeIDs); if (!isHavePrivilege) { response.Status = false; response.Message = Messages.UnauthorizedAccess; } if (response.Status) { response = new LoketHandler(_unitOfWork).ProcessRegistration(request); } return(response); }