public void UpdatePropertyDetails(Property property, Dictionary <int, int> propertyValues)
 {
     using (PropertyContext propertyContext = new PropertyContext())
     {
         propertyContext.Entry(property).State = EntityState.Modified;
         PropertyValues values     = new PropertyValues();
         bool           flag       = true;
         List <int>     propertyId = (from valuesObject in propertyContext.PropertyValues where property.PropertyId == valuesObject.PropertyId select valuesObject.PropertyId).ToList();
         int            count      = 0;
         while (flag)
         {
             if (property.PropertyId == (propertyId[0]))
             {
                 foreach (KeyValuePair <int, int> item in propertyValues)
                 {
                     values       = (from valueObject in propertyContext.PropertyValues where valueObject.ValueId == item.Key select valueObject).Single();
                     values.Value = propertyValues[item.Key];
                     propertyContext.SaveChanges();
                 }
                 count++;
             }
             if (count == propertyValues.Count)
             {
                 flag = false;
             }
         }
         propertyContext.SaveChanges();
     }
 }
Пример #2
0
        public int SignUp(User user)
        {
            PropertyContext propertyContext = new PropertyContext();

            propertyContext.User.Add(user);
            return(propertyContext.SaveChanges());
        }
 //buyer
 public int Create(BuyerProperty buyerProperty)
 {
     using (PropertyContext propertyContext = new PropertyContext())
     {
         propertyContext.BuyerProperty.Add(buyerProperty);
         return(propertyContext.SaveChanges());
     }
 }
 public void Delete(int landId)
 {
     using (PropertyContext propertyContext = new PropertyContext())
     {
         Property propertyvalue = propertyContext.Property.Find(landId);
         propertyContext.Property.Remove(propertyvalue);
         List <PropertyValues> propertyValues = (from value in propertyContext.PropertyValues where value.PropertyId == landId select value).ToList();
         for (int index = 0; index < propertyValues.Count; index++)
         {
             propertyContext.PropertyValues.Remove(propertyValues[index]);
         }
         propertyContext.SaveChanges();
     }
 }
 public void AddPropertyValue(PropertyValues propertyValues, int [] Value, int[] PropertyFeature)
 {
     using (PropertyContext propertyContext = new PropertyContext())
     {
         int index = 0;
         foreach (int value in Value)
         {
             propertyValues.Value             = value;
             propertyValues.PropertyFeatureId = PropertyFeature[index];
             index++;
             propertyContext.PropertyValues.Add(propertyValues);
             propertyContext.SaveChanges();
         }
     }
 }
        public void AcceptRequest(BuyerProperty buyerProperty)
        {
            buyerProperty.Status = "Accept";
            Property property = new Property();

            property.PropertyId     = buyerProperty.PropertyId;
            property.PropertyTypeID = buyerProperty.PropertyTypeID;
            property.UserId         = buyerProperty.UserId;
            property.Image          = buyerProperty.Image;
            property.Location       = buyerProperty.Location;
            property.Price          = buyerProperty.Price;
            property.Area           = buyerProperty.Area;
            using (PropertyContext propertyContext = new PropertyContext())
            {
                propertyContext.Property.Add(property);
                propertyContext.SaveChanges();
            }
        }