// GET: PTenants/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PTenant pTenant = PropertyService.GetPropertyTenantById(id ?? 0);

            if (pTenant == null)
            {
                return(HttpNotFound());
            }
            var properties = PropertyService.GetAllValidProperties().Select(m => new SelectListItem()
            {
                Text = m.FullAddress + "(" + m.PropertyCode + ")", Value = m.PPropertyId.ToString()
            }).ToList();

            ViewBag.CurrentPropertyId = new SelectList(properties, "Value", "Text", pTenant.CurrentPropertyId);

            return(View(pTenant));
        }
Ejemplo n.º 2
0
        public void DeletePropertyTenant(int pTenantId)
        {
            PTenant pTenant = _currentDbContext.PTenants.Find(pTenantId);

            _currentDbContext.PTenants.Remove(pTenant);
            _currentDbContext.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "PTenantId,TenantCode,TenantYCode,TenantFullName,TenantSalutation,TenancyStatus,TenancyCategory,TenancyAdded,TenancyStarted,TenancyRenewDate,TenancyPeriodMonths,SiteId,SyncRequiredFlag,CurrentPropertyCode,AddressLine1,AddressLine2,AddressLine3,AddressLine4,AddressPostcode,HomeTelephone,WorkTelephone1,WorkTelephone2,WorkTelephoneFax,MobileNumber,Email,CurrentPropertyId")] PTenant pTenant, FormCollection form)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }

            if (ModelState.IsValid)
            {
                PropertyService.CreatePropertyTenant(pTenant, CurrentUserId);
                if (form["ReturnUrl"] != null)
                {
                    return(Redirect(form["ReturnUrl"]));
                }
                return(RedirectToAction("Index"));
            }

            var properties = PropertyService.GetAllValidProperties().Select(m => new SelectListItem()
            {
                Text = m.FullAddress + "(" + m.PropertyCode + ")", Value = m.PPropertyId.ToString()
            }).ToList();

            ViewBag.CurrentPropertyId = new SelectList(properties, "Value", "Text", pTenant.CurrentPropertyId);

            return(View(pTenant));
        }
Ejemplo n.º 4
0
 public PTenant SavePTenant(PTenant model, int userId)
 {
     model.CreatedUserId   = userId;
     model.DateCreated     = DateTime.UtcNow;
     model.IsCurrentTenant = true;
     _currentDbContext.PTenants.Add(model);
     _currentDbContext.SaveChanges();
     return(model);
 }
 public JsonResult _PTenentSubmit(PTenant model)
 {
     try
     {
         model = PropertyService.SavePTenant(model, CurrentUserId);
         return(Json(new { error = false, id = model.PTenantId, code = model.TenantFullName }));
     }
     catch (Exception exp)
     {
         return(Json(new { error = true, msg = exp.Message }));
     }
 }
Ejemplo n.º 6
0
 public PTenant CreatePropertyTenant(PTenant pTenant, int userId)
 {
     pTenant.TenancyAdded  = DateTime.UtcNow;
     pTenant.DateCreated   = DateTime.UtcNow;
     pTenant.DateUpdated   = DateTime.UtcNow;
     pTenant.CreatedUserId = userId;
     if (pTenant.CurrentPropertyId.HasValue && pTenant.CurrentPropertyId > 0)
     {
         pTenant.IsCurrentTenant = true;
     }
     _currentDbContext.PTenants.Add(pTenant);
     _currentDbContext.SaveChanges();
     return(pTenant);
 }
Ejemplo n.º 7
0
        public PTenant UpdatePropertyTenant(PTenant tenant, int userId)
        {
            var currentProperty = GetPropertyById(tenant.CurrentPropertyId ?? 0);

            if (currentProperty != null)
            {
                tenant.CurrentPropertyCode = currentProperty.PropertyCode;
            }

            tenant.DateUpdated   = DateTime.UtcNow;
            tenant.UpdatedUserId = userId;
            _currentDbContext.Entry(tenant).State = EntityState.Modified;
            _currentDbContext.SaveChanges();
            return(tenant);
        }
        // GET: PTenants/Details/5
        public ActionResult Details(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PTenant pTenant = PropertyService.GetPropertyTenantById(id ?? 0);

            if (pTenant == null)
            {
                return(HttpNotFound());
            }
            return(View(pTenant));
        }
        public ActionResult Edit(PTenant pTenant)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (ModelState.IsValid)
            {
                PropertyService.UpdatePropertyTenant(pTenant, CurrentUserId);
                return(RedirectToAction("Index"));
            }
            var properties = PropertyService.GetAllValidProperties().Select(m => new SelectListItem()
            {
                Text = m.FullAddress + "(" + m.PropertyCode + ")", Value = m.PPropertyId.ToString()
            }).ToList();

            ViewBag.CurrentPropertyId = new SelectList(properties, "Value", "Text", pTenant.CurrentPropertyId);

            return(View(pTenant));
        }