コード例 #1
0
 public ActionResult Create(LeaseTermViewModel model, int pId = -1)
 {
     if (ModelState.IsValid)
     {
         if (pId > 0)
         {
             model.PropertyId = pId;
         }
         LeaseTermModel serviceModel = new LeaseTermModel
         {
             PropertyId  = model.PropertyId,
             Description = model.Description,
             Duration    = model.Duration,
             MonthlyRent = model.MonthlyRent,
             IsActive    = true
         };
         var result = this.Service.CreateLeaseTerm((((OwnerModel)Session["SelectedAccount"]).Id), serviceModel);
         if (result)
         {
             return(RedirectToAction("Details", "Properties", new { pId = model.PropertyId }));
         }
         ModelState.AddModelError("", "The lease term could not be created. Check if you have the right permissions to perfomr this action and if the selected property exists.");
     }
     OnCreate();
     return(View(model));
 }
コード例 #2
0
        public bool CreateLeaseTerm(int ownerId, LeaseTermModel term)
        {
            var prop = Entities.Properties.Find(term.PropertyId);

            if (prop != null && prop.OwnerId == ownerId)
            {
                var termDb = new LeaseTerm
                {
                    PropertyId  = term.PropertyId,
                    Description = term.Description,
                    Duration    = term.Duration,
                    MonthlyRent = term.MonthlyRent,
                    IsActive    = term.IsActive
                };
                Entities.LeaseTerms.Add(termDb);
                Entities.SaveChanges();
                return(true);
            }
            return(false);
        }
コード例 #3
0
ファイル: Extensions.cs プロジェクト: betterprops/digiprops
 public static LeaseTermViewModel ToViewModel(this LeaseTermModel model)
 {
     return(Mapper.Map <LeaseTermModel, LeaseTermViewModel>(model));
 }