Esempio n. 1
0
 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;
 }
Esempio n. 2
0
        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());
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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 }));
        }