public IHttpActionResult Approve([FromBody] SOWApprovalDTO sOWApproval)
        {
            ThrowIfUserHasNoRole(approvalRole);
            if (sOWApproval == null)
            {
                throw new KairosException("Missing model parameter");
            }

            if (sOWApproval.SOW_PK == 0)
            {
                throw new KairosException("Put method is not allowed because the requested primary key is '0' (zero) .");
            }

            using (var sOWApprovalHandler = new SOWApprovalHandler(Db, ActiveUser, new SOWValidator(), new SOWFactory(Db, ActiveUser), new SOWAssignFactory(Db, ActiveUser), new SOWTrackFactory(Db, ActiveUser), new SOWQuery(Db), AccessControl))
            {
                using (var transaction = new TransactionScope())
                {
                    var saveResult = sOWApprovalHandler.Save(sOWApproval, DateTime.Now);
                    transaction.Complete();
                    if (saveResult.Success)
                    {
                        return(Ok(new SuccessResponse(saveResult.Model, saveResult.Message)));
                    }
                    return(Ok(new ErrorResponse(ServiceStatusCode.ValidationError, saveResult.ValidationResult, saveResult.Message)));
                }
            }
        }
Esempio n. 2
0
        public ModelValidationResult ValidateApprovalModel(SOWApprovalDTO sowApprovalDTO)
        {
            ModelValidator validator = new ModelValidator();

            validator.Validate(sowApprovalDTO);
            return(validator.ValidationResult);
        }