Ejemplo n.º 1
0
        public JsonResult AddedProperty(PropertyResponse model)
        {
            CreatePropertyRequest request = new CreatePropertyRequest();
            request.PropertyID = model.PropertyID;
            request.StreetName = model.StreetName;
            request.StreetNumber = model.StreetNumber;
            request.City = model.City;
            request.ComplexName = model.ComplexName;
            request.PostalCode = model.PostalCode;
            request.PropertyID = model.PropertyID;
            request.PropertyType = model.PropertyType;
            request.UnitNumber = model.UnitNumber;
            request.Suburb = model.Suburb;

            var result = ApiWrapper.Post<PropertyResponse>("api/property/add", request);

            return Json(result);
        }
Ejemplo n.º 2
0
        public JsonResult Add(CreatePropertyRequest request)
        {
            Property property = null;

            if (request.PropertyID <= 0)
            {
                property = new Property();
                property.PropertyID = request.PropertyID;
                property.PropertyType = request.PropertyType;
                property.UnitNumber = request.UnitNumber;
                property.ComplexName = request.ComplexName;
                property.StreetNumber = request.StreetNumber;
                property.StreetName = request.StreetName;
                property.Suburb = request.Suburb;
                property.City = request.City;
                property.PostalCode = request.PostalCode;

                db.Properties.Add(property);
                db.SaveChanges();
            }
            else
            {
                property = db.Properties.Where(x => x.PropertyID == request.PropertyID).FirstOrDefault();
                if (property != null)
                {
                    property.PropertyID = request.PropertyID;
                    property.PropertyType = request.PropertyType;
                    property.UnitNumber = request.UnitNumber;
                    property.ComplexName = request.ComplexName;
                    property.StreetNumber = request.StreetNumber;
                    property.StreetName = request.StreetName;
                    property.Suburb = request.Suburb;
                    property.City = request.City;
                    property.PostalCode = request.PostalCode;

                    db.SaveChanges();
                }

            }

            return Json(property);
        }