private static void MapLeaserEditModelToLeaserObject(LeaserEditModel leaserEditModel, Leaser leaser) { leaser.Address = leaserEditModel.Address; leaser.ContactNumber = leaserEditModel.ContactNumber; leaser.Name = leaserEditModel.Name; leaser.AssetInfo.Description = leaserEditModel.Description; leaser.AssetInfo.Location = leaserEditModel.AssetLocation; leaser.AssetInfo.Type = leaserEditModel.AssetType; }
internal async Task <bool> UpdateLeaserEditDetails(LeaserEditModel leaserEditModel) { var leaser = await this.leaserRepository. GetLeaserByIdAsync(leaserEditModel.ID); if (leaser == null) { return(false); } MapLeaserEditModelToLeaserObject(leaserEditModel, leaser); return(await this.leaserRepository.SaveChangesAsync()); }
internal async Task <LeaserEditModel> GetLeaserEditDetails(int leaserId) { var leaser = await this.leaserRepository .GetLeaserByIdAsync(leaserId); if (leaser != null) { LeaserEditModel leaserEditModel = CreateLeaserEditModelFromLeaser(leaser); return(leaserEditModel); } return(null); }
public async Task <IActionResult> EditDetails(LeaserEditModel leaserEditModel) { if (ModelState.IsValid) { var result = await this.leaserService.UpdateLeaserEditDetails(leaserEditModel); if (result == false) { // should redirect to custom error page // for now show as badrequest return(BadRequest()); } return(RedirectToAction("Index")); } return(RedirectToAction("EditDetails", new { id = leaserEditModel.ID })); }