示例#1
0
 public int AddMerchant(MERCHANT c)
 {
     db = new WEBGIAYEntities();
     db.MERCHANTS.Add(c);
     db.SaveChanges();
     return(c.MAMERCHANT);
 }
        public static IEnumerable <Shop> GetShops(string file, MERCHANT merchant)
        {
            var doc = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(file));

            var deals = doc["deals"];

            foreach (var deal in deals)
            {
                var counter = 0;

                foreach (var location in deal.SelectToken("redemptionLocations"))
                {
                    var shop = new Shop
                    {
                        Source          = "AMAZON",
                        Longitude       = GetProperty(location, "longitude"),
                        Latitude        = GetProperty(location, "latitude"),
                        PostalCode      = GetProperty(location, "addressPostalCode"),
                        PhoneNumber     = GetProperty(location, "phoneNumber"),
                        Geography       = GetProperty(location, "geography.displayName"),
                        UniqueId        = GetProperty(deal, "asin") + "/SHOP/" + counter,
                        StateOrProvince = GetProperty(location, "addressStateOrProvince"),
                        Street1         = GetProperty(location, "addressStreet1"),
                        Street2         = GetProperty(location, "addressStreet2"),
                    };


                    counter++;

                    yield return(shop);
                }
            }
        }
示例#3
0
        private static void SaveOffers(wp_user user, MERCHANT merchant, Func <string, MERCHANT, IEnumerable <DailyOffer> > callback, string file)
        {
            log.DebugFormat("Getting deals for <{0}>.", merchant);
            var dailyOffers = callback(file, merchant);

            log.DebugFormat("Parsing deals for <{0}>.", merchant);
            SaveOffers(user, dailyOffers, merchant);
        }
示例#4
0
        private static void SaveShops(wp_user user, IEnumerable <Shop> shops, MERCHANT merchant)
        {
            log.DebugFormat("Saving shops for <{0}>.", merchant);

            ShopCreationService.Save(user, shops.ToArray());

            log.DebugFormat("Finished saving shops for <{0}>.", merchant);
        }
示例#5
0
        private static void SaveShops(wp_user user, MERCHANT merchant, Func <string, MERCHANT, IEnumerable <Shop> > callback, string file)
        {
            log.DebugFormat("Getting shops for <{0}>.", merchant);
            var shops = callback(file, merchant);

            log.DebugFormat("Parsing shops for <{0}>.", merchant);
            SaveShops(user, shops, merchant);
        }
示例#6
0
        private static string Download(MERCHANT merchant, Func <MERCHANT, string> getDataFeed)
        {
            log.DebugFormat("Downloading feed for <{0}>.", merchant);
            var file = getDataFeed(merchant);

            log.DebugFormat("Downloaded feed for <{0}> to <{1}>.", merchant, file);
            return(file);
        }
        public MERCHANT FindMerchant(string merchantCode)
        {
            object[] paremeter =
            {
                new SqlParameter("@MerchantCode", merchantCode)
            };
            MERCHANT res = db.Database.SqlQuery <MERCHANT>("sp_GetMerchant @MerchantCode", paremeter).FirstOrDefault();

            return(res);
        }
示例#8
0
        public bool active(int idme)
        {
            bool     check = false;
            MERCHANT m     = db.MERCHANTS.Find(idme);

            m.TINHTRANG = 1;
            db.SaveChanges();
            check = true;
            return(check);
        }
示例#9
0
 public ActionResult register(REGISTERViewModel r)
 {
     if (ModelState.IsValid)
     {
         MERCHANTDAL dal   = new MERCHANTDAL();
         var         email = dal.kiemtratendangnhap(r.EMAIL);
         var         tendn = dal.kiemtratendangnhap(r.TENDANGNHAP);
         var         cmd   = dal.kiemtracmnd(r.CMND);
         if (email != null)
         {
             ModelState.AddModelError("", "Email đã đươc sử dụng");
         }
         if (tendn != null)
         {
             ModelState.AddModelError("", "Tên dăng nhập đã đươc sử dụng");
         }
         if (cmd != null)
         {
             ModelState.AddModelError("", "CMND đã đươc sử dụng");
         }
         else
         {
             var m = new MERCHANT();
             m.TENDANGNHAP  = r.TENDANGNHAP;
             m.TENMERCHANT  = r.TENMERCHANT;
             m.MATKHAU      = MD5Encryptor.MD5Hash(r.MATKHAU);
             m.DIACHI       = r.DIACHI;
             m.EMAIL        = r.EMAIL;
             m.NGAYSINH     = r.NGAYSINH;
             m.SDT          = r.SDT;
             m.NGAYDK       = DateTime.Today;
             m.TINHTRANG    = 0;
             m.SOTINHIENTAI = 0;
             m.SOLANBIKHOA  = 0;
             m.RATING       = 0;
             m.CMND         = r.CMND;
             var ver = dal.newme(m);
             if (ver > 0)
             {
                 ViewBag.Success = "Đăng kí thành công. Vui lòng kiểm tra email để kích hoạt tài khoản";
                 BuildEmailTemplate(ver);
             }
             else
             {
                 ModelState.AddModelError("", "Đăng kí không thành công");
             }
         }
     }
     return(View(r));
 }
        public async Task <IHttpActionResult> DeleteMERCHANT(string id)
        {
            MERCHANT mERCHANT = await db.MERCHANT.FindAsync(id);

            if (mERCHANT == null)
            {
                return(NotFound());
            }

            db.MERCHANT.Remove(mERCHANT);
            await db.SaveChangesAsync();

            return(Ok(mERCHANT));
        }
        public static string Download(MERCHANT merchant)
        {
            var credCache = new CredentialCache
            {
                {
                    new Uri(DIGEST_URI), "Digest",
                    new NetworkCredential(Config.AMAZON_USERNAME, Config.AMAZON_PASSWORD)
                }
            };

            var client = new HttpClient(new HttpClientHandler {
                Credentials = credCache
            });
            var inFile = AbstractDataFeed.DownloadFeed(URL, client);

            return(AbstractDataFeed.ExtractContents(inFile));
        }
 public bool UpdateAgentOfMerchant(string merchantCode, MERCHANT merchant)
 {
     try
     {
         object[] paremeter =
         {
             new SqlParameter("@MerchantCode", merchantCode),
             new SqlParameter("@AgentCode",    merchant.AgentCode)
         };
         db.Database.ExecuteSqlCommand("exec sp_UpdateAgentOfMerchant @MerchantCode, @AgentCode", paremeter);
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
        public bool UpdateMerchant(string id, MERCHANT merchant)
        {
            //m nhap merchant name vao
            try
            {
                object[] parameter =
                {
                    new SqlParameter("@MerchantCode",     merchant.MerchantCode),
                    new SqlParameter("@MerchantName",     merchant.MerchantName),
                    new SqlParameter("@BackEndProcessor", merchant.BackEndProcessor),
                    new SqlParameter("@Status",           merchant.Status ?? (object)DBNull.Value),
                    new SqlParameter("@Owner",            merchant.Owner ?? (object)DBNull.Value),
                    new SqlParameter("@MerchantType",     merchant.MerchantType ?? (object)DBNull.Value),
                    new SqlParameter("@Address1",         merchant.Address1 ?? (object)DBNull.Value),
                    new SqlParameter("@Address2",         merchant.Address2 ?? (object)DBNull.Value),
                    new SqlParameter("@Address3",         merchant.Address3 ?? (object)DBNull.Value),
                    new SqlParameter("@CityCode",         merchant.CityCode),
                    new SqlParameter("@Zip",              merchant.Zip ?? System.Data.SqlTypes.SqlInt32.Null),
                    new SqlParameter("@Phone",            string.IsNullOrEmpty(merchant.Phone)?"":merchant.Phone),
                    new SqlParameter("@Fax",              string.IsNullOrEmpty(merchant.Fax)?"":merchant.Fax),
                    new SqlParameter("@Email",            string.IsNullOrEmpty(merchant.Fax)?"":merchant.Fax),
                    new SqlParameter("@ApprovalDate",     merchant.ApprovalDate ?? (object)DBNull.Value),
                    new SqlParameter("@CloseDate",        merchant.CloseDate ?? (object)DBNull.Value),
                    new SqlParameter("@BankCardDBA",      merchant.BankCardDBA ?? (object)DBNull.Value),
                    new SqlParameter("@FirstActiveDate",  merchant.FirstActiveDate ?? (object)DBNull.Value),
                    new SqlParameter("@LastActiveDate",   merchant.LastActiveDate ?? (object)DBNull.Value),
                    new SqlParameter("@AgentCode",        merchant.AgentCode)
                };
                string sql = "sp_Editmerchant @MerchantCode, @MerchantName,@BackEndProcessor ,@Status, @Owner, @MerchantType"
                             + ",@Address1,@Address2,@Address3,@CityCode,@Zip,@Phone,@Fax,@Email, @ApprovalDate,@CloseDate,@BankCardDBA,@FirstActiveDate"
                             + ",@LastActiveDate,@AgentCode";
                db.Database.ExecuteSqlCommand(sql, parameter);


                return(true);
            }
            catch (Exception ex)
            {
                System.Console.Write(ex.ToString());
                return(false);
            }
        }
示例#14
0
        /* Public Methods. */

        public static IEnumerable <DailyOffer> GetDeals(string fileContents, MERCHANT merchant)
        {
            var doc = XDocument.Load(fileContents);

            return(from product in doc.Descendants("prod")
                   where product.Attribute("in_stock").Value == "yes"
                   select new ShopWindowDailyOffer
            {
                Language = GetAttribute(product, "lang"),
                AWThumb = GetChild(product, "awThumb"),
                MerchantThumbnail = GetChild(product, "mThumb"),
                MerchantLink = GetChild(product, "mLink"),
                MerchantImage = GetChild(product, "mImage"),
                WebOffer = GetAttribute(product, "web_offer"),
                InStock = GetAttribute(product, "in_stock"),
                StockQuantity = GetAttribute(product, "stock_quantity"),
                ProductMerchantId = GetChild(product, "pId"),
                PreOrder = GetAttribute(product, "pre_order"),
                BrandName = GetChild(product, "brandName"),
                Description = GetChild(product, "desc"),
                Warranty = GetChild(product, "warranty"),
                Spec = GetChild(product, "spec"),
                Title = GetChild(product, "name"),
                ImageUrl = GetChild(product, "awImage"),
                Merchant = merchant.ToString(),
                Source = "SHOP_WINDOW",
                Promo = GetChild(product, "promo"),
                UniqueId = product.Attribute("id").Value,
                OfferEndTime = GetChild(product, "valTo"),
                OfferStartTime = GetChild(product, "valFrom"),
                BuyNowPrice = GetChild(product, "buynow"),
                StorePrice = GetChild(product, "store"),
                RecommendedRetailPrice = GetChild(product, "rrp"),
                Delivery = GetChild(product, "delivery"),
                PurchaseUrl = GetChild(product, "awTrack"),
                Value = GetValue(product),
                Products = new List <string> {
                    GetChild(product, "awCat").Replace("&", "and")
                }
            });
        }
示例#15
0
        /* Public Methods. */

        public static String Execute(
            MERCHANT merchant,
            wp_user user,
            Func <MERCHANT, string> getDataFeed,
            Func <string, MERCHANT, IEnumerable <DailyOffer> > getOffers,
            Func <string, MERCHANT, IEnumerable <Shop> > getShops = null)
        {
            var file = Download(merchant, getDataFeed);

            if (getShops != null)
            {
                SaveShops(user, merchant, getShops, file);
            }

            if (getOffers != null)
            {
                SaveOffers(user, merchant, getOffers, file);
            }

            return(file);
        }
示例#16
0
        public static IEnumerable <DailyOffer> GetDeals(string file, MERCHANT merchant)
        {
            var doc = JsonConvert.DeserializeObject <JObject>(File.ReadAllText(file));

            var deals = doc["deals"];

            foreach (var deal in deals)
            {
                var counter = 0;

                foreach (var option in deal.SelectToken("options"))
                {
                    var dailyOffer = new AmazonDailyOffer
                    {
                        Title        = GetProperty(option, "title"),
                        Description  = GetProperty(deal, "description"),
                        ImageUrl     = GetProperty(deal, "imageUrl"),
                        FinePrint    = GetProperty(deal, "finePrint"),
                        Price        = GetProperty(option, "price.amountInBaseUnit"),
                        Value        = GetProperty(option, "value.amountInBaseUnit"),
                        Source       = merchant.ToString(),
                        UniqueId     = GetProperty(deal, "asin") + "/CODE/" + counter,
                        OfferEndTime = new DateTime(long.Parse(GetProperty(deal, "offerEndTime")) / 1000).ToString(),
                        Merchant     = GetProperty(deal, "merchant.displayName"),
                        Products     = new List <string> {
                            GetProperty(deal, "category.name")
                        },
                        Geographies = deal.SelectToken("geographies").Select(x => x.SelectToken("displayName").Value <String>())
                    };

                    counter++;

                    yield return(dailyOffer);
                }
            }
        }
示例#17
0
 public int newme(MERCHANT m)
 {
     db.MERCHANTS.Add(m);
     db.SaveChanges();
     return(m.MAMERCHANT);
 }
 public static void GetDeals(MERCHANT merchant, wp_user user)
 {
     AbstractProvider.Execute(merchant, user, DataFeed.Download, Parser.GetDeals);
 }
示例#19
0
        public ActionResult SendMail(FormCollection form)
        {
            var model    = Session[CommonConstants.USER_SESSION];
            var temp     = new USER_INFORMATION();
            var merchant = new MERCHANT();

            if (model != null)
            {
                temp = (USER_INFORMATION)model;

                HttpClient          client   = new AccessAPI().Access();
                HttpResponseMessage response = client.GetAsync(string.Format("api/MERCHANT/FindMerchant?merchantCode={0}", temp.UserName)).Result;
                if (response.IsSuccessStatusCode)
                {
                    merchant = response.Content.ReadAsAsync <MERCHANT>().Result;
                }
            }
            else
            {
                return(View("Index"));
            }

            var fbMail = new Mail();

            fbMail.Subject = form["Subject"];
            fbMail.Content = form["Content"];
            var Signature = "\n\n-------------\n" + merchant.MerchantName + "\n" + merchant.Owner + "\n" + merchant.Address1
                            + "\n" + merchant.Email + "\n" + merchant.Phone;

            fbMail.MailMaster   = WebConfigurationManager.AppSettings["toAddress"];
            fbMail.MailMerchant = WebConfigurationManager.AppSettings["fromAddress"];
            fbMail.Password     = WebConfigurationManager.AppSettings["Password"];
            var fromAddress = new MailAddress(fbMail.MailMerchant);
            var toAddress   = new MailAddress(fbMail.MailMaster);

            var smtp = new SmtpClient
            {
                Host                  = WebConfigurationManager.AppSettings["host"],
                Port                  = int.Parse(WebConfigurationManager.AppSettings["port"]),
                EnableSsl             = true,
                DeliveryMethod        = SmtpDeliveryMethod.Network,
                UseDefaultCredentials = true,
                Credentials           = new NetworkCredential(fromAddress.Address, fbMail.Password)
            };

            using (var message = new MailMessage(fromAddress, toAddress)
            {
                Subject = fbMail.Subject,
                Body = fbMail.Content + Signature
            })
            {
                try
                {
                    smtp.Send(message);
                    TempData["Message"] = "true";
                    return(RedirectToAction("Index"));
                }
                catch (Exception)
                {
                    TempData["Message"] = "false";
                    return(RedirectToAction("Index"));
                }
            }
        }
示例#20
0
        /* Private. */

        private static void SaveOffers(wp_user user, IEnumerable <DailyOffer> dailyOffers, MERCHANT merchant)
        {
            log.DebugFormat("Saving deals for <{0}>.", merchant);

            try
            {
                DailyOfferCreationService.Save(user, dailyOffers.ToArray());
            }
            catch (Exception e)
            {
                log.FatalFormat(e.Message);
                log.FatalFormat(e.StackTrace);
                throw;
            }

            log.DebugFormat("Finished saving deals for <{0}>.", merchant);
        }