Ejemplo n.º 1
0
 public async Task <string> Create([FromBody] LeaseCreateViewModel model)
 {
     try
     {
         var lease = mapper.Map <Lease>(model);
         return(await leaseRepository.Create(lease));
     }
     catch (Exception ex)
     {
         throw new Exception($"Error POSTing lease: {ex.Message}");
     }
 }
Ejemplo n.º 2
0
 public ActionResult Create(LeaseCreateViewModel model)
 {
     if (ModelState.IsValid)
     {
         var result = Service.CreateLease(model.ToServiceModel(), ((OwnerModel)Session["SelectedAccount"]).Id, User.Identity.Name);
         if (result)
         {
             return(RedirectToAction("Details", "Properties", new { pId = model.PropertyId }));
         }
         ModelState.AddModelError("", "Request could not be completed.");
     }
     OnCreate();
     return(View(model));
 }
Ejemplo n.º 3
0
        public ActionResult Create(int aId)
        {
            var leaseApplication = Service.GetLeaseApplicationById(aId, ((OwnerModel)Session["SelectedAccount"]).Id, User.Identity.Name);
            var newLease         = new LeaseCreateViewModel
            {
                PropertyId                = leaseApplication.PropertyId,
                PropertyAddress           = leaseApplication.PropertyAddress,
                LeaseApplicationId        = aId,
                Duration                  = leaseApplication.Duration,
                MonthlyRent               = leaseApplication.MonthlyRent,
                TenantFullName            = leaseApplication.TenantFullName,
                StartDate                 = DateTime.Now.AddDays(15),
                EndDate                   = DateTime.Now.AddDays(3).AddMonths((int)leaseApplication.Duration),
                TenantId                  = leaseApplication.TenantId,
                LeaseStatusId             = 2,
                LeaseStatus               = "Active",
                InitialDeposit            = 3 * leaseApplication.MonthlyRent,
                InitialDepositDescription = "Includes first month, last month and security deposit."
            };

            OnCreate();
            return(View(newLease));
        }
Ejemplo n.º 4
0
 public static LeaseModel ToServiceModel(this LeaseCreateViewModel model)
 {
     return(Mapper.Map <LeaseCreateViewModel, LeaseModel>(model));
 }