public HttpResponseMessage PostBuilding(PropertyBuilding building)
 {
     try
     {
         building.PostDate = DateTime.Now;
         foreach (var item in building.Images)
         {
             item.CreatedDate = DateTime.Now;
             item.MainImage = false;
         }
         db.Buildings.Add(building);
         db.SaveChanges();
         return Request.CreateResponse(HttpStatusCode.Created);
     }
     catch (Exception ex)
     {
         return Request.CreateResponse(HttpStatusCode.BadRequest);
     }
 }
        public HttpResponseMessage UpdateBuilding(PropertyBuilding building)
        {
            try
            {
                var count = db.Buildings.Where(e => e.ID == building.ID).Count();
                var item = building;
                if (count != 0)
                {
                    item = db.Buildings.First(e => e.ID == building.ID);
                    item.BathRoom = building.BathRoom;
                    item.BedRoom = building.BedRoom;
                    item.BuildingSquare = building.BuildingSquare;
                    item.Content = building.Content;
                    item.LandSquare = building.LandSquare;
                    item.Price = building.Price;
                    item.Title = building.Title;
                    item.Images = building.Images;
                }
                    db.Buildings.AddOrUpdate(item);
                    db.SaveChanges();
                    return Request.CreateResponse(HttpStatusCode.OK);

                return Request.CreateResponse(HttpStatusCode.NotFound);
            }
            catch (Exception)
            {
                return Request.CreateResponse(HttpStatusCode.Created);
            }
        }
 public HttpResponseMessage UpdateBuilding(PropertyBuilding building)
 {
     try
     {
         var item = db.Buildings.First(e => e.ID == building.ID);
         if (item != null)
         {
             item = building;
             db.SaveChanges();
             return Request.CreateResponse(HttpStatusCode.OK);
         }
         return Request.CreateResponse(HttpStatusCode.NotFound);
     }
     catch (Exception)
     {
         return Request.CreateResponse(HttpStatusCode.Created);
     }
 }