Esempio n. 1
0
        public ActionResult DeleteConfirmed(long id)
        {
            merchant merchant = db.merchants.Find(id);

            db.merchants.Remove(merchant);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Esempio n. 2
0
        public List <product> Get(int Id)
        {
            merchant tMerchant = (from m in DB.merchant_advertisers
                                  where m.merchant_id == Id
                                  select m.merchant).FirstOrDefault();
            List <product> tProducts = tMerchant.products.ToList();

            return(tProducts);
        }
Esempio n. 3
0
 public ActionResult Edit([Bind(Include = "merchant_id,cmnd,tenshop,anhshop,diemdanhgia,ngaydangky,taikhoanpaypal,capdo_id,customer_id")] merchant merchant)
 {
     if (ModelState.IsValid)
     {
         db.Entry(merchant).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.capdo_id    = new SelectList(db.capdoes, "capdo_id", "tencapdo", merchant.capdo_id);
     ViewBag.customer_id = new SelectList(db.customers, "customer_id", "username", merchant.customer_id);
     return(View(merchant));
 }
Esempio n. 4
0
        public bool Process(int MerchantId)
        {
            merchant tMerchant = (from m in DB.merchants where m.id == MerchantId select m).SingleOrDefault();

            if (tMerchant != null)
            {
                system_configs tConfig = (from s in DB.system_configs select s).SingleOrDefault();
                if (tConfig != null)
                {
                }
            }
            return(true);
        }
Esempio n. 5
0
        // GET: merchants/Delete/5
        public ActionResult Delete(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            merchant merchant = db.merchants.Find(id);

            if (merchant == null)
            {
                return(HttpNotFound());
            }
            return(View(merchant));
        }
Esempio n. 6
0
        // GET: merchants/Edit/5
        public ActionResult Edit(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            merchant merchant = db.merchants.Find(id);

            if (merchant == null)
            {
                return(HttpNotFound());
            }
            ViewBag.capdo_id    = new SelectList(db.capdoes, "capdo_id", "tencapdo", merchant.capdo_id);
            ViewBag.customer_id = new SelectList(db.customers, "customer_id", "username", merchant.customer_id);
            return(View(merchant));
        }
Esempio n. 7
0
        public bool Process(String User, int MerchantID, String OwnerCellphone)
        {
            try
            {
                //Validate Phonenumber
                ValidateNumberTwillio tNumberValidation = new ValidateNumberTwillio();
                if (!tNumberValidation.Validate(OwnerCellphone))
                {
                    return(false);
                }

                merchant tMerchant = (from m in DB.merchants
                                      where m.id == MerchantID &&
                                      m.opt_out == "N" select m).FirstOrDefault();
                if (tMerchant == null)
                {
                    return(false);
                }

                tMerchant.cumulative_referrals += 1;

                List <user_merchant_referrals> tUsers = (from u in DB.user_merchant_referrals
                                                         where u.cell_phone_entered_by_user == OwnerCellphone
                                                         select u).ToList();
                List <DateTime> tcount = (from d in tUsers
                                          group d by d.created_at into grp
                                          where grp.Count() > 1
                                          select grp.Key).ToList();
                if (tcount == null || tcount.Count == 0)
                {
                    return(false);
                }
                tMerchant.permanent_cell_phone_number = OwnerCellphone;

                RegistrationCodeModel tRegCodeModel = new RegistrationCodeModel();
                int tRegCode = tRegCodeModel.Get(MerchantID);

                String tFreeReferalsThresholdStr = (from sc in DB.system_configs
                                                    where sc.tag == "free_referals_threshold"
                                                    select sc.value).FirstOrDefault();
                int tFreeReferalsThreshold = Int32.Parse(tFreeReferalsThresholdStr);

                string tSidStr = (from sid in DB.system_configs
                                  where sid.tag == "EXOTEL_SID"
                                  select sid.value).FirstOrDefault();
                String tTokenStr = (from tok in DB.system_configs
                                    where tok.tag == "EXOTEL_TOKEN"
                                    select tok.value).FirstOrDefault();

                String tFromPhoneStr = (from tok in DB.system_configs
                                        where tok.tag == "SALLIKASU_PHONE"
                                        select tok.value).FirstOrDefault();

                SendSMSExotel tExotelSMS = new SendSMSExotel(tSidStr, tTokenStr);
                if (tMerchant.cumulative_referrals < tFreeReferalsThreshold)
                {
                    tExotelSMS.execute(tFromPhoneStr, OwnerCellphone, "REFER_SALIKASU"); //TODO: we are going to have to put a string here.
                }
                else if (tMerchant.cumulative_referrals * (1 + 10 / 100) > tFreeReferalsThreshold)
                {
                    tExotelSMS.execute(tFromPhoneStr, OwnerCellphone, "SALIKASU_DELIST"); //TODO: we are going to have to put a string here.
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }