public async Task <Result <AffiliateManageModel> > UpdateAffiliate([FromBody] AffiliateManageModel model) { if (!Validate(model)) { return(null); } var affiliate = await _mapper.FromModelAsync(model); var sUserId = _userManager.GetUserId(Request.HttpContext.User); int userId; if (Int32.TryParse(sUserId, out userId)) { affiliate.IdEditedBy = userId; } if (affiliate.Id > 0) { affiliate = await _affiliateService.UpdateAsync(affiliate); } else { affiliate = await _affiliateService.InsertAsync(affiliate); } var toReturn = await _mapper.ToModelAsync <AffiliateManageModel>(affiliate); toReturn.IsConfirmed = model.IsConfirmed; toReturn.PublicUserId = model.PublicUserId; return(toReturn); }