Exemplo n.º 1
0
 public static int CreateFirm(string name, string adress, double longitude, double latitude, string desc, string city,
                              int firmId, int systemId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Firm firm = new Firm();
             firm.Firm_Owner_Id  = firmId;
             firm.name           = name;
             firm.address        = adress;
             firm.longitude      = longitude;
             firm.latitude       = latitude;
             firm.description    = desc;
             firm.city           = city;
             firm.Sytem_Admin_Id = systemId;
             ce.Firms.Add(firm);
             ce.SaveChanges();
             return(firm.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 2
0
        public static bool UpdateCostomer(Costumer costumer)
        {
            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var result = ce.Costumers.SingleOrDefault(b => b.Id == costumer.Id);
                    if (result != null)
                    {
                        result.User = costumer.User;

                        result.Coupon_Order    = costumer.Coupon_Order;
                        result.User_Prefrences = costumer.User_Prefrences;
                        result.age             = costumer.age;
                        result.latitude        = costumer.latitude;
                        result.longitude       = costumer.longitude;
                        result.gender          = costumer.gender;
                        ce.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 3
0
 public static bool UpdateFirm(Firm firm)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.Firms.SingleOrDefault(b => b.Id == firm.Id);
             if (result != null)
             {
                 result.Firm_Owner_Id  = firm.Firm_Owner_Id;
                 result.Firm_Owner     = firm.Firm_Owner;
                 result.Sytem_Admin    = firm.Sytem_Admin;
                 result.Sytem_Admin_Id = firm.Sytem_Admin_Id;
                 result.address        = firm.address;
                 result.city           = firm.city;
                 result.category       = firm.category;
                 result.description    = firm.description;
                 result.name           = firm.name;
                 result.latitude       = firm.latitude;
                 result.longitude      = firm.longitude;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 4
0
 public static int CreateSocialNet(string username, string password, string sendData, string recivedData, string authToken,
                                   int id)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             SocialNetworkProfile socialNetwork = new SocialNetworkProfile
             {
                 username    = username,
                 password    = password,
                 sendData    = sendData,
                 recivedData = recivedData,
                 authToken   = authToken,
                 User_Id     = id
             };
             ce.SocialNetworkProfiles.Add(socialNetwork);
             ce.SaveChanges();
             return(socialNetwork.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 5
0
 public static bool UpdateSocialNetProfile(SocialNetworkProfile socialNetworkProfile)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.SocialNetworkProfiles.SingleOrDefault(b => b.Id == socialNetworkProfile.Id);
             if (result != null)
             {
                 result.User_Id     = socialNetworkProfile.User_Id;
                 result.User        = socialNetworkProfile.User;
                 result.authToken   = socialNetworkProfile.authToken;
                 result.password    = socialNetworkProfile.password;
                 result.recivedData = socialNetworkProfile.recivedData;
                 result.sendData    = socialNetworkProfile.sendData;
                 result.username    = socialNetworkProfile.username;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 6
0
 public static int CreateCoupon(string name, string description, double orignalPrice, double aggregatedRank,
                                DateTime lastDate, int adminID, int creatorId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Coupon coupon = new Coupon
             {
                 Admin_Approvel = adminID,
                 name           = name,
                 description    = description,
                 originalPrice  = orignalPrice,
                 aggregatedRank = aggregatedRank,
                 lastDateforUse = lastDate,
                 creatorId      = creatorId
             };
             ce.SaveChanges();
             return(coupon.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 7
0
 public static bool UpdateCoupon(Coupon coupon)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.Coupons.SingleOrDefault(b => b.Id == coupon.Id);
             if (result != null)
             {
                 result.User                 = coupon.User;
                 result.creatorId            = coupon.creatorId;
                 result.Coupon_Alert         = coupon.Coupon_Alert;
                 result.aggregatedRank       = coupon.aggregatedRank;
                 result.description          = coupon.description;
                 result.Coupon_Order         = coupon.Coupon_Order;
                 result.Coupons_Social_Cupon = coupon.Coupons_Social_Cupon;
                 result.discountPrice        = coupon.discountPrice;
                 result.lastDateforUse       = coupon.lastDateforUse;
                 result.name                 = coupon.name;
                 result.Categories           = coupon.Categories;
                 result.Admin_Approvel       = coupon.Admin_Approvel;
                 result.originalPrice        = coupon.originalPrice;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 8
0
 public static int CreateCouponOrder(int couponId, DateTime date, string recepit, string creditApproval, double rank,
                                     string rankDesc, string qr, double serialKey)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Coupon_Order co = new Coupon_Order
             {
                 coupon_id      = couponId,
                 date           = date,
                 recepit        = recepit,
                 creditApproval = creditApproval,
                 isUsed         = false,
                 rank           = rank,
                 rankDesc       = rankDesc,
                 qrForOrder     = qr,
                 serialKey      = serialKey
             };
             ce.Coupon_Order.Add(co);
             ce.SaveChanges();
             return(co.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 9
0
 public static int CreateSocialCupon(int couponId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Coupons_Social_Cupon couponsSocial = new Coupons_Social_Cupon();
             couponsSocial.Id = couponId;
             ce.Coupons_Social_Cupon.Add(couponsSocial);
             ce.SaveChanges();
             return(couponId);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 10
0
 public static int CreateAdmin(int user_id)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Sytem_Admin admin = new Sytem_Admin();
             admin.Id = user_id;
             ce.Sytem_Admin.Add(admin);
             ce.SaveChanges();
             return(admin.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 11
0
 public static int CreateUserPref(int userId, int categoryId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             User_Prefrences userPrefrences = new User_Prefrences {
                 Users_Id = userId, category = categoryId
             };
             ce.User_Prefrences.Add(userPrefrences);
             ce.SaveChanges();
             return(userPrefrences.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 12
0
 public static int FirmOwner(int user_id, int systemAdminId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Firm_Owner firmOwner = new Firm_Owner {
                 Id = user_id, Sytem_Admin_Id = systemAdminId
             };
             ce.Firm_Owner.Add(firmOwner);
             ce.SaveChanges();
             return(firmOwner.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 13
0
 public static int CreateUser(string userName, string passwd, string email)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             User user = new User {
                 username = userName, password = passwd, email = email
             };
             ce.Users.Add(user);
             ce.SaveChanges();
             return(user.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 14
0
 public static bool UpdateSocialCoupon(Coupons_Social_Cupon socialCupon)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.Coupons_Social_Cupon.SingleOrDefault(b => b.Id == socialCupon.Id);
             if (result != null)
             {
                 result.Coupon = socialCupon.Coupon;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 15
0
 public static int CreateCouponAlert(int couponId, int alertType, string text)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Coupon_Alert ca = new Coupon_Alert();
             ca.coupon_Id  = couponId;
             ca.alert_type = alertType;
             ca.text       = text;
             ce.Coupon_Alert.Add(ca);
             ce.SaveChanges();
             return(ca.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }
Exemplo n.º 16
0
        public static bool RemoveCoupon(int CouponId)
        {
            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var itemToRemove = ce.Coupons.SingleOrDefault(x => x.Id == CouponId); //returns a single item.

                    if (itemToRemove != null)
                    {
                        ce.Coupons.Remove(itemToRemove);
                        ce.SaveChanges();
                    }
                }
            }
            catch (Exception)
            {
                return(false);
            }
            return(true);
        }
Exemplo n.º 17
0
 public static bool CreateCouponAlert(int userId, int couponAlertId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             UsersCoupon_Alert usersCouponAlert = new UsersCoupon_Alert
             {
                 User_Id         = userId,
                 Coupon_Alert_Id = couponAlertId
             };
             ce.UsersCoupon_Alert.Add(usersCouponAlert);
             ce.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 18
0
 public static bool UpdateUserPref(User_Prefrences userPrefrences)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.User_Prefrences.SingleOrDefault(b => b.Id == userPrefrences.Id);
             if (result != null)
             {
                 result.Users_Id = userPrefrences.Users_Id;
                 result.category = userPrefrences.category;
                 result.Costumer = userPrefrences.Costumer;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 19
0
 public static bool UpdateFirmOwner(Firm_Owner firmOwner)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var result = ce.Firm_Owner.SingleOrDefault(b => b.Id == firmOwner.Id);
             if (result != null)
             {
                 result.Sytem_Admin    = firmOwner.Sytem_Admin;
                 result.Sytem_Admin_Id = firmOwner.Sytem_Admin_Id;
                 result.User           = firmOwner.User;
                 result.Firms          = firmOwner.Firms;
                 ce.SaveChanges();
             }
         }
     }
     catch (Exception)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 20
0
 public static bool CreateCouponCategory(int couponId, int categoryId)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var c        = (from x in ce.Coupons where x.Id == couponId select x);
             var category = (from x in ce.Categories where x.Id == categoryId select x);
             foreach (Coupon coupon in c)
             {
                 foreach (Category category1 in category)
                 {
                     coupon.Categories.Add(category1);
                 }
             }
             ce.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 21
0
 public static int CreateCostumer(int user_id, int gender, double age, double longtitdue, double latitude)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             Costumer costumer = new Costumer
             {
                 Id        = user_id,
                 age       = age,
                 gender    = gender,
                 latitude  = latitude,
                 longitude = longtitdue
             };
             ce.Costumers.Add(costumer);
             ce.SaveChanges();
             return(costumer.Id);
         }
     }
     catch (Exception)
     {
         return(-1);
     }
 }