Esempio n. 1
0
        // GET: PProperties/Edit/5
        public ActionResult Edit(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PProperty pProperty = PropertyService.GetPropertyById(id.Value);

            if (pProperty == null)
            {
                return(HttpNotFound());
            }
            var landlords = PropertyService.GetAllValidPropertyLandlords().Select(m => new SelectListItem()
            {
                Value = m.PLandlordId.ToString(), Text = m.LandlordFullname + "(" + m.LandlordCode + ")"
            });

            ViewBag.CurrentLandlordId = new SelectList(landlords, "Value", "Text", pProperty.CurrentLandlordId);

            return(View(pProperty));
        }
Esempio n. 2
0
        public PProperty SavePProperty(PProperty model, int userId)
        {
            if (model.PPropertyId > 0)
            {
                model.UpdatedUserId = userId;
                model.DateUpdated   = DateTime.UtcNow;
            }
            else
            {
                model.CreatedUserId = userId;
                model.DateCreated   = DateTime.UtcNow;
                _currentDbContext.PProperties.Add(model);
            }

            _currentDbContext.SaveChanges();

            if (model.CurrentPTenentId > 0)
            {
                var tenant = _currentDbContext.PTenants.FirstOrDefault(m => m.PTenantId == model.CurrentPTenentId);
                if (tenant != null)
                {
                    tenant.CurrentPropertyCode            = model.PropertyCode;
                    tenant.CurrentProperty                = model;
                    tenant.IsCurrentTenant                = true;
                    _currentDbContext.Entry(tenant).State = EntityState.Modified;
                    _currentDbContext.SaveChanges();
                }
            }
            return(model);
        }
Esempio n. 3
0
        public ActionResult Create(
            [Bind(Include =
                      "PPropertyId,PropertyCode,AddressLine1,AddressLine2,AddressLine3,AddressLine4,AddressLine5,AddressPostcode,PropertyStatus,IsVacant,DateAvailable,DateAdded,PropertyBranch,TenancyMonths,SiteId,SyncRequiredFlag,LetDate,CurrentLandlordId")]
            PProperty pProperty, FormCollection form)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (ModelState.IsValid)
            {
                pProperty.IsVacant  = !pProperty.LetDate.HasValue;
                pProperty.DateAdded = DateTime.UtcNow;
                PropertyService.SavePProperty(pProperty, CurrentUserId);
                return(RedirectToAction("Index"));
            }

            var landlords = PropertyService.GetAllValidPropertyLandlords().Select(m => new SelectListItem()
            {
                Value = m.PLandlordId.ToString(),
                Text  = m.LandlordFullname + "(" + m.LandlordCode + ")"
            });

            ViewBag.CurrentLandlordId = new SelectList(landlords, "Value", "Text", pProperty.CurrentLandlordId);

            return(View(pProperty));
        }
        private static void LoadHtmlPageProperties(SidenavFile file)
        {
            List <PProperty> properties  = new List <PProperty>();
            string           fullContent = Utils.GetFullFileConent(file.InputFilePath);
            HtmlDocument     doc         = new HtmlDocument();

            doc.LoadHtml(fullContent);
            doc.RemoveComments();

            HtmlNode[] propertyNodes = doc.DocumentNode.Descendants("PProperty").ToArray();
            foreach (HtmlNode node in propertyNodes)
            {
                string propertyName  = HttpUtility.UrlEncode(node.GetAttributeValue("name", string.Empty));
                string propertyValue = node.GetAttributeValue("value", string.Empty);
                if (!string.IsNullOrEmpty(propertyName))
                {
                    PProperty property = new PProperty(propertyName, propertyValue);
                    properties.Add(property);
                }

                node.Remove();
            }

            file.SetContent(properties, doc.DocumentNode.OuterHtml);
        }
Esempio n. 5
0
        public void DeletePropertyById(int pProrpertyId)
        {
            PProperty pProperty = GetPropertyById(pProrpertyId);

            pProperty.IsDeleted = true;
            _currentDbContext.Entry(pProperty).State = EntityState.Modified;
            _currentDbContext.SaveChanges();
        }
 public JsonResult _PropertySubmit(PProperty model)
 {
     try
     {
         model = PropertyService.SavePProperty(model, CurrentUserId);
         return(Json(new { error = false, id = model.PPropertyId, code = model.PropertyCode }));
     }
     catch
     {
         return(Json(new { error = true }));
     }
 }
        private static void LoadMarkdownPageProperties(SidenavFile file)
        {
            List <PProperty> properties  = new List <PProperty>();
            string           fullContent = Utils.GetFullFileConent(file.InputFilePath);

            string[] lines = fullContent.Split(Configuration.NewlineChars, StringSplitOptions.None);
            if (lines.Length == 0)
            {
                file.SetContent(properties, string.Empty);
                return;
            }

            int   lineNum = 0;
            Regex regex   = new Regex("Property:*,*");

            while (regex.IsMatch(lines[lineNum]) && lineNum < lines.Length)
            {
                string   data          = lines[lineNum].Substring(9);
                string[] datas         = data.Split(',');
                string   propertyName  = datas[0].Trim();
                string   propertyValue = datas[1].Trim();
                if (!string.IsNullOrEmpty(propertyName) && !string.IsNullOrEmpty(propertyValue))
                {
                    PProperty property = new PProperty(propertyName, propertyValue);
                    properties.Add(property);
                }

                lineNum++;
            }

            StringBuilder builder = new StringBuilder();
            bool          first   = true;

            for (int i = lineNum; i < lines.Length; i++)
            {
                if (!first)
                {
                    builder.Append(Configuration.DefaultNewlineChar);
                }

                builder.Append(lines[i]);
                first = false;
            }

            var pipeline = new MarkdownPipelineBuilder().UseAdvancedExtensions().Build();
            var markdown = Markdown.ToHtml(builder.ToString(), pipeline);

            file.SetContent(properties, markdown);
        }
Esempio n. 8
0
        // GET: PProperties/Delete/5
        public ActionResult Delete(int?id)
        {
            if (!caSession.AuthoriseSession())
            {
                return(Redirect((string)Session["ErrorUrl"]));
            }
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            PProperty pProperty = PropertyService.GetPropertyById(id.Value);

            if (pProperty == null)
            {
                return(HttpNotFound());
            }
            return(View(pProperty));
        }
Esempio n. 9
0
        public PProperty GetPropertyById(int pPropertyId)
        {
            PProperty pproperty = _currentDbContext.PProperties.Find(pPropertyId);;

            return(pproperty);
        }