コード例 #1
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);
 }
コード例 #2
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);
 }
コード例 #3
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);
     }
 }
コード例 #4
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);
        }
コード例 #5
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);
     }
 }
コード例 #6
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);
 }
コード例 #7
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);
     }
 }
コード例 #8
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);
     }
 }
コード例 #9
0
        public static User GetUser(int id)
        {
            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    return(ce.Users.SingleOrDefault(x => x.Id == id));
                }
            }
            catch (Exception)
            {
                return(null);

                throw;
            }
            return(null);
        }
コード例 #10
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);
     }
 }
コード例 #11
0
        public static List <Category> GetCategories()
        {
            List <Category> categories = new List <Category>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var c = (from x in ce.Categories select x);
                    categories.AddRange(c);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(categories);
        }
コード例 #12
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);
     }
 }
コード例 #13
0
        public static List <Coupon_Alert> GetCouponAlerts(int couponId)
        {
            var alert = new List <Coupon_Alert>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var c = (from x in ce.Coupon_Alert where x.coupon_Id == couponId select x);
                    alert.AddRange(c);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(alert);
        }
コード例 #14
0
        public static List <Coupon> GetCoupons()
        {
            List <Coupon> coupons = new List <Coupon>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var c = (from x in ce.Coupons select x);
                    coupons.AddRange(c);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(coupons);
        }
コード例 #15
0
        public static List <Firm> GetFirms()
        {
            List <Firm> firms = new List <Firm>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var a = (from x in ce.Firms select x);
                    firms.AddRange(a);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(firms);
        }
コード例 #16
0
        public static List <AlertType> GetAlertTypes()
        {
            List <AlertType> alertTypes = new List <AlertType>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var a = (from x in ce.AlertTypes select x);
                    alertTypes.AddRange(a);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(alertTypes);
        }
コード例 #17
0
        public static List <User_Prefrences> GetUserPrefrenceses(int userid)
        {
            List <User_Prefrences> userPrefrenceses = new List <User_Prefrences>();

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var users = (from x in ce.User_Prefrences where x.Users_Id == userid select x);
                    userPrefrenceses.AddRange(users);
                }
            }
            catch (Exception)
            {
                return(null);
            }
            return(null);
        }
コード例 #18
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);
     }
 }
コード例 #19
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);
     }
 }
コード例 #20
0
 public static int GetFirmOwnerId(string username)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var firmOwner = (from x in ce.Firm_Owner where x.User.username == username select x);
             foreach (Firm_Owner owner in firmOwner)
             {
                 return(owner.Id);
             }
         }
     }
     catch (Exception)
     {
         return(-1);
     }
     return(-1);
 }
コード例 #21
0
 public static Costumer GetCostumer(int id)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var users = (from x in ce.Costumers where x.Id == id select x);
             foreach (Costumer user in users)
             {
                 return(user);
             }
         }
     }
     catch (Exception)
     {
         return(null);
     }
     return(null);
 }
コード例 #22
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);
     }
 }
コード例 #23
0
 public static SocialNetworkProfile GetSocialNetworkProfileForUser(int userid)
 {
     try
     {
         using (couponEntities2 ce = new couponEntities2())
         {
             var users = (from x in ce.SocialNetworkProfiles where x.User_Id == userid select x);
             foreach (SocialNetworkProfile user in users)
             {
                 return(user);
             }
         }
     }
     catch (Exception)
     {
         return(null);
     }
     return(null);
 }
コード例 #24
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);
 }
コード例 #25
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);
     }
 }
コード例 #26
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);
        }
コード例 #27
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);
     }
 }
コード例 #28
0
        public static int GetAdminId(string username)
        {
            int ans = -1;

            try
            {
                using (couponEntities2 ce = new couponEntities2())
                {
                    var admin = (from x in ce.Sytem_Admin where x.User.username == username select x);
                    foreach (Sytem_Admin sytemAdmin in admin)
                    {
                        return(sytemAdmin.Id);
                    }
                }
            }
            catch (Exception)
            {
                ans = -1;
            }
            return(ans);
        }
コード例 #29
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);
 }
コード例 #30
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);
 }