Exemple #1
0
        public async Task <object> ConditionData(HouseObjectViewModel obj)
        {
            Dictionary <string, object> conditions = new();

            Type typeObj = obj.GetType();

            PropertyInfo[] propertyList = typeObj.GetProperties();

            foreach (var property in propertyList)
            {
                conditions.Add(property.Name, property.GetValue(typeObj, null));
            }
            return(await _houseObjectService.GetHouseObjectsByCondition(conditions));
        }
        public Task <OperationResult> UpdateHouseObject(HouseObjectViewModel obj)
        {
            var houseObj = new HouseObject
            {
                HouseObjectId         = obj.HouseObjectId,
                DealDate              = obj.DealDate,
                Address               = obj.Address,
                HouseAge              = obj.HouseAge,
                County                = obj.County,
                IsParkingSpace        = obj.IsParkingSpace,
                ParkingSpacePrice     = obj.ParkingSpacePrice,
                ParkingSpaceSqureFeet = obj.ParkingSpaceSqureFeet,
                Region                = obj.Region,
                Remark                = obj.Remark,
                Source                = obj.Source,
                SquareFeet            = obj.SquareFeet,
                SquareFeetUnitPrice   = obj.SquareFeetUnitPrice,
                TotalFloor            = obj.TotalFloor,
                TotalPrice            = obj.TotalPrice,
                Type       = obj.Type,
                ImgUrl     = obj.ImgUrl,
                Floor      = obj.Floor,
                CreateTime = DateTime.UtcNow.AddHours(8),
                EditeTime  = DateTime.UtcNow.AddHours(8),
                CreateUser = "******",
                EditeUser  = "******",
            };
            var housingLayout = new HousingLayout
            {
                HousingLayoutId = obj.HousingLayoutId,
                Bathroom        = obj.Bathroom,
                LivingRoom      = obj.LivingRoom,
                Room            = obj.Room,
                EditeTime       = DateTime.UtcNow.AddHours(8),
                CreateTime      = DateTime.UtcNow.AddHours(8),
                CreateUser      = "******",
                EditeUser       = "******"
            };
            var result = _repo.Insert(houseObj, housingLayout);

            return(result);
        }
        // GET: HouseObjectController/Details/ -> Här går vi in på enskilda objekt, int id parametern plockar ut det objekt som skall visas på en ny sida.
        public async Task <ActionResult> Details(int id)
        {
            HouseObjectViewModel houses = null;

            using (var client = new HttpClient())
            {
                var result = await client.GetAsync(_config.GetValue <string>("prod") + "HouseObjects/" + id);

                if (result.IsSuccessStatusCode)
                {
                    houses = await result.Content.ReadAsAsync <HouseObjectViewModel>();
                }
                else
                {
                    return(NotFound());
                }

                return(View(houses));
            }
        }
        // POST: Intresseanmälan för enskilda objekt.
        public async Task <ActionResult> RegOfIntrest(HouseObjectViewModel objects)
        {
            if (!ModelState.IsValid)
            {
                return(View("Details", objects));
            }

            using var client = new HttpClient();
            var result = await client.PostAsJsonAsync(_config.GetValue <string>("prod") + "HouseObjects/" + objects.HouseObjectId + "/RegOfIntrest/", objects);

            if (result.IsSuccessStatusCode)
            {
                ViewData["Message"] = "Tack för din intresseanmälan";
                return(View("Registration"));
            }
            else if (result.StatusCode == HttpStatusCode.Conflict)
            {
                ViewData["Message"] = "Du har redan gjort en intresseanmälan på detta objekt";
                return(View("Registration"));
            }

            return(NotFound());
        }
Exemple #5
0
 public async Task <OperationResult> DeleteData(HouseObjectViewModel obj)
 {
     return(await _houseObjectService.DeleteHouseObject(obj.HouseObjectId));
 }
Exemple #6
0
 public async Task <OperationResult> UpdateData(HouseObjectViewModel obj)
 {
     return(await _houseObjectService.UpdateHouseObject(obj));
 }