Exemplo n.º 1
0
        // GET: Merchants/Create
        public ActionResult QRCode(int?merchantId)
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }

            List <QRCodeModel> qRCodelist = new List <QRCodeModel>();

            foreach (var s in merchant.Staffs)
            {
                QRCodeModel qrCodes = new QRCodeModel();
                //MerchantStaff merchantStaff = new MerchantStaff();
                //merchantStaff.MerchantGuid = merchant.Guid;
                //merchantStaff.MerchantName = merchant.Name;
                //merchantStaff.StaffGuid = s.Guid;
                //List<MerchantStaff> list = new List<MerchantStaff>();
                string        merchantStaff = merchant.Guid + ":" + s.Guid + ":" + merchant.Name;
                List <string> list          = new List <string>();
                list.Add(merchantStaff);
                var content = JsonConvert.SerializeObject(list);
                qrCodes.QRCode      = QRCodeService.GenerateQRCode(content);
                qrCodes.Merchant    = merchant.Name;
                qrCodes.Staff       = s.Name;
                qrCodes.PhoneNumber = s.PhoneNumber;
                qRCodelist.Add(qrCodes);
            }

            //string encrypted = ConfigurationManager.AppSettings["encryptedvalue"];
            //string decrypted = CryptoService.Decrypt(encrypted);
            ViewBag.MerchantId = merchantId;
            return(View(qRCodelist));
        }
Exemplo n.º 2
0
        // GET: Merchants/Settlements
        public ActionResult Index()
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }
            return(View(db.Settlements.Where(s => s.Merchant_Id == merchant.Id)));
        }
Exemplo n.º 3
0
 // GET: Admin/Managers/Create
 public ActionResult Create()
 {
     using (MerchantService _merchantService = new MerchantService(User.Identity))
     {
         Merchant merchant = _merchantService.Merchant();
         ViewBag.MerchantName        = merchant.Name;
         ViewBag.MerchantDescription = merchant.Description;
     }
     return(View());
 }
Exemplo n.º 4
0
        // GET: Merchants/Vouchers
        //public ActionResult Index()
        //{
        //    return View(db.Vouchers.ToList());
        //}

        // GET: Merchants/Vouchers
        public ActionResult Index(DateTime settledOn)
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }
            var vouchers = db.Vouchers.Where(v => v.Merchant_Id == merchant.Id && v.SettledOn == settledOn);

            return(View(vouchers.ToList()));
        }
Exemplo n.º 5
0
        // GET: Merchants/Staffs/Delete/5
        public ActionResult Delete(int id)
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }

            Staff staff = merchant.Staffs.Find(s => s.Id == id);

            if (staff == null)
            {
                return(HttpNotFound());
            }
            return(View(staff));
        }
Exemplo n.º 6
0
        // GET: Merchants/Merchants/Details/5
        public ActionResult Details()
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }
            if (merchant != null)
            {
                return(View(merchant));
            }
            else
            {
                object Nothing = null;
                return(RedirectToAction("Unauthorized", "Account", new { area = Nothing }));
            }
        }
Exemplo n.º 7
0
        // GET: Admin/Managers/Delete/5
        public ActionResult Delete(int id)
        {
            Merchant merchant = null;

            using (MerchantService _merchantService = new MerchantService(User.Identity))
            {
                merchant = _merchantService.Merchant();
            }

            Manager manager = merchant.Managers.Find(m => m.Id == id);

            if (manager == null)
            {
                return(HttpNotFound());
            }

            return(View(manager));
        }
Exemplo n.º 8
0
        public ActionResult Create([Bind(Include = "Id,Username")] Manager manager)
        {
            if (ModelState.IsValid)
            {
                Merchant merchant = null;
                using (MerchantService _merchantService = new MerchantService(User.Identity))
                {
                    merchant                    = _merchantService.Merchant();
                    ViewBag.MerchantName        = merchant.Name;
                    ViewBag.MerchantDescription = merchant.Description;

                    //TODO: Update with NopCommerce table
                    var user = db.Database.SqlQuery <int>("SELECT Id FROM AspNetUsers WHERE Username = '******'").FirstOrDefault();
                    if (user == 0)
                    {
                        ModelState.AddModelError("", "Username not found.");
                    }
                    else
                    {
                        try
                        {
                            //TODO: Update with NopCommerce table
                            var roleId = db.Database.SqlQuery <int>("SELECT Id FROM [AspNetRoles] WHERE Name = 'Managers'").FirstOrDefault();
                            var role   = db.Database.ExecuteSqlCommand("INSERT INTO AspNetUserRoles (UserId, RoleId) VALUES (" + user + "," + roleId + ")");
                            manager.Customer_Id = user;
                            merchant.Managers.Add(manager);
                            _merchantService._db.Entry(merchant).State = EntityState.Modified;
                            _merchantService._db.SaveChanges();
                            return(RedirectToAction("../Merchants/Details/"));
                        }
                        catch (Exception e)
                        {
                            ModelState.AddModelError("", "Username is already a manager of another merchant.");
                        }
                    }
                }
            }
            return(View());
        }
Exemplo n.º 9
0
 public ActionResult Create([Bind(Include = "Id,Guid,Name,PhoneNumber,Block")] Staff staff)
 {
     try
     {
         using (MerchantService _merchantService = new MerchantService(User.Identity))
         {
             Merchant merchant = _merchantService.Merchant();
             ViewBag.MerchantName        = merchant.Name;
             ViewBag.MerchantDescription = merchant.Description;
             Guid guid = Guid.NewGuid();
             staff.Guid = guid.ToString();
             merchant.Staffs.Add(staff);
             _merchantService._db.Entry(merchant).State = EntityState.Modified;
             _merchantService._db.SaveChanges();
             return(RedirectToAction("../Merchants/Details/"));
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError("", e.Message);
         return(View());
     }
 }