Exemplo n.º 1
0
        /// <summary>
        /// Update agreement
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel> UpdateAgreementAsync(UpdateAgreementViewModel model)
        {
            if (model == null)
            {
                return(new InvalidParametersResultModel());
            }

            var agreement = await _context.Agreements.FirstOrDefaultAsync(x => x.Id.Equals(model.Id));

            if (agreement == null)
            {
                return(new NotFoundResultModel());
            }

            agreement.Name                  = model.Name;
            agreement.LeadId                = model.LeadId;
            agreement.OrganizationId        = model.OrganizationId;
            agreement.ContactId             = model.ContactId;
            agreement.OrganizationAddressId = model.OrganizationAddressId;
            agreement.ProductId             = model.ProductId;
            agreement.ContractTemplateId    = model.ContractTemplateId;
            agreement.Values                = model.Values;
            agreement.Commission            = model.Commission;
            agreement.UserId                = model.UserId;
            agreement.Description           = model.Description;

            _context.Agreements.Update(agreement);
            return(await _context.PushAsync());
        }
 public async Task <JsonResult> UpdateAgreement([Required] UpdateAgreementViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return(JsonModelStateErrors());
     }
     return(await JsonAsync(_agreementService.UpdateAgreementAsync(model)));
 }