Beispiel #1
0
        public void Validate(PurchaseOrderPusatRequest request, out PurchaseOrderPusatResponse response)
        {
            response = new PurchaseOrderPusatResponse();

            if ((request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString())) || (request.Action != null && request.Action.Equals(ClinicEnums.Action.APPROVE.ToString())) || (request.Action != null && request.Action.Equals(ClinicEnums.Action.VALIDASI.ToString())))
            {
                if (request.Action != null && request.Action.Equals(ClinicEnums.Action.DELETE.ToString()))
                {
                    ValidateForDelete(request, out response);
                }
                else if (request.Action.Equals(ClinicEnums.Action.APPROVE.ToString()))
                {
                    ValidateForApprove(request, out response);
                }
                else
                {
                    ValidateForValidasi(request, out response);
                }
            }
            else
            {
                bool isHavePrivilege = true;

                if (request.Data.ponumber == null || String.IsNullOrWhiteSpace(request.Data.ponumber))
                {
                    errorFields.Add("Ponumber");
                }

                if (errorFields.Any())
                {
                    response.Status  = false;
                    response.Message = string.Format(Messages.ValidationErrorFields, String.Join(",", errorFields));
                }

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

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

                if (response.Status)
                {
                    response = new PurchaseOrderPusatHandler(_unitOfWork).CreateOrEdit(request);
                }
            }
        }
Beispiel #2
0
        private void ValidateForApprove(PurchaseOrderPusatRequest request, out PurchaseOrderPusatResponse response)
        {
            response = new PurchaseOrderPusatResponse();

            if (request.Action == ClinicEnums.Action.APPROVE.ToString())
            {
                bool isHavePrivilege = IsHaveAuthorization(EDIT_M_PURCHASEORDERPUSAT, request.Data.Account.Privileges.PrivilegeIDs);
                if (!isHavePrivilege)
                {
                    response.Status  = false;
                    response.Message = Messages.UnauthorizedAccess;
                }
            }

            if (response.Status)
            {
                response = new PurchaseOrderPusatHandler(_unitOfWork).ApproveData(request);
            }
        }