Esempio n. 1
0
 public bool ConfirmBid()
 {
     try
     {
         RealEntities db   = new RealEntities();
         var          bids = db.bids.Where(b => b.property_id == PropertyId && b.bid_id != BidId);
         if (null != bids)
         {
             foreach (var b in bids)
             {
                 b.status = ( int )BidStatus.Rejected;
             }
         }
         var bid = db.bids.Where(b => b.bid_id == BidId).FirstOrDefault();
         if (null != bid)
         {
             bid.status = ( int )BidStatus.Approved;
         }
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Esempio n. 2
0
 internal bool Place()
 {
     try
     {
         RealEntities db  = new RealEntities();
         bid          bid = new bid();
         bid.property_id = PropertyId;
         bid.buyer_id    = BuyerId;
         bid.status      = ( int )Status;
         db.bids.Add(bid);
         db.SaveChanges();
         bid_price bp = new bid_price();
         bp.bid_id          = bid.bid_id;
         bp.apartment_price = HousePrice;
         bp.plot_price      = LandPrice;
         db.bid_price.Add(bp);
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
 public bool ChangeStatus(PropertyStatus status)
 {
     try
     {
         RealEntities db   = new RealEntities();
         property     prop = db.properties.Where(p => p.property_id == PropertyId).FirstOrDefault();
         prop.status = ( int )status;
         db.SaveChanges();
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
        public bool AddProperty()
        {
            try
            {
                property      prop    = new property();
                List <Marker> markers = GetMarkers();
                RealEntities  db      = new RealEntities();
                prop.name      = Name;
                prop.area      = Area;
                prop.latitude  = Latitude;
                prop.longitude = Longitude;
                prop.seller_id = SellerId;
                prop.category  = Category;
                prop.status    = 1;
                db.properties.Add(prop);
                db.SaveChanges();
                min_price price = new min_price();
                switch (prop.category)
                {
                case 1:
                {
                    price.plot_price      = LandPrice;
                    price.apartment_price = 0;
                    break;
                }

                case 2:
                {
                    price.plot_price      = LandPrice;
                    price.apartment_price = HousePrice;
                    break;
                }

                case 3:
                {
                    price.plot_price      = 0;
                    price.apartment_price = HousePrice;
                    break;
                }
                }
                price.property_id = prop.property_id;
                db.min_price.Add(price);
                db.SaveChanges();
                db.properties.Attach(prop);
                foreach (var marker in markers)
                {
                    RealEntities ldb = new RealEntities();
                    landmark     lm  = ldb.landmarks.Where(l => l.latitude == marker.Lat && l.longitude == marker.Lng && l.landmarktype == marker.Type).FirstOrDefault();
                    if (null == lm)
                    {
                        lm = new landmark();
                        lm.landmarktype = marker.Type;
                        lm.latitude     = marker.Lat;
                        lm.longitude    = marker.Lng;
                        lm.name         = marker.Name;
                        ldb.landmarks.Add(lm);
                        ldb.SaveChanges();
                    }
                    if (0 != lm.landmark_id)
                    {
                        landmark mark = db.landmarks.Where(l => l.landmark_id == lm.landmark_id).Single();
                        db.landmarks.Attach(mark);
                        prop.landmarks.Add(mark);
                    }
                }
                db.SaveChanges();

                foreach (HttpPostedFileBase image in Images)
                {
                    //Checking file is available to save.
                    if (image != null)
                    {
                        image img = new image();
                        img.property_id = prop.property_id;
                        MemoryStream target = new MemoryStream();
                        image.InputStream.CopyTo(target);
                        img.image1 = target.ToArray();
                        db.images.Add(img);
                    }
                }
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
            }
            return(false);
        }
Esempio n. 5
0
        public bool RegisterUser()
        {
            try
            {
                RealEntities db = new RealEntities();
                user         u  = new user();
                u.user_name  = UserName;
                u.password   = Password;
                u.first_name = FirstName;
                u.last_name  = LastName;
                u.address    = Address;
                u.pan_no     = PAN;
                u.mob_no     = Mob;
                u.email      = Email;
                u.status_id  = 1;
                db.users.Add(u);
                db.SaveChanges();
                UserId = u.user_id;
                switch (Type)
                {
                case UserType.Buyer:
                {
                    buyer b = new buyer();
                    b.user_id  = u.user_id;
                    b.max_area = MaxArea;
                    b.min_area = MinArea;
                    b.min_cost = MinCost;
                    b.max_cost = MaxCost;
                    db.buyers.Add(b);
                    break;
                }

                case UserType.Both:
                {
                    buyer b = new buyer();
                    b.user_id  = u.user_id;
                    b.max_area = MaxArea;
                    b.min_area = MinArea;
                    b.min_cost = MinCost;
                    b.max_cost = MaxCost;
                    db.buyers.Add(b);
                    seller s = new seller();
                    s.seller_type = 2;
                    s.user_id     = u.user_id;
                    db.sellers.Add(s);
                    break;
                }

                case UserType.Seller:
                {
                    seller s = new seller();
                    s.seller_type = 1;
                    s.user_id     = u.user_id;
                    db.sellers.Add(s);
                    break;
                }
                }
                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
            }
            return(false);
        }