示例#1
0
        public Result <AgreementModel> DeleteAgreementModel(string uniqueId)
        {
            if (_agreementRepository.AgreementExists(uniqueId) == false)
            {
                Result <AgreementModel> result = new NotFoundResult <AgreementModel>("Agreement not found!");
                if (_errorService.AddError(uniqueId, result.ResultType, result.Errors, "Delete") == false)
                {
                    Console.WriteLine("Error service failed");
                }
                return(result);
            }
            try
            {
                bool success = _agreementRepository.DeleteAgreement(uniqueId);

                if (!success)
                {
                    Result <AgreementModel> result = new BadRequestResult <AgreementModel>("Bad request: Agreement update failed!");
                    if (_errorService.AddError(uniqueId, result.ResultType, result.Errors, "Delete") == false)
                    {
                        Console.WriteLine("Error service failed");
                    }
                    return(result);
                }
            }
            catch
            {
                Result <AgreementModel> result = new UnexpectedResult <AgreementModel>();
                if (_errorService.AddError(uniqueId, result.ResultType, result.Errors, "Put") == false)
                {
                    Console.WriteLine("Error service failed");
                }
                return(result);
            }


            return(new SuccessResult <AgreementModel>());
        }