public ActionResult DeleteConfirmed(long id)
        {
            MerchantStore store = db.MerchantStores.Find(id);

            db.MerchantStores.Remove(store);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Address,createdDate,Image1,Image2,Image3,Image4")] MerchantStore merchantStore)
 {
     if (ModelState.IsValid)
     {
         db.Entry(merchantStore).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(merchantStore));
 }
예제 #3
0
        public ActionResult Create([Bind(Include = "Id,Name,Address,createdDate,Image1,Image2,Image3,Image4")] MerchantStore merchantStore)
        {
            if (ModelState.IsValid)
            {
                db.MerchantStores.Add(merchantStore);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(merchantStore));
        }
        public ActionResult Detail(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            MerchantStore store = db.MerchantStores.Find(id);

            if (store == null)
            {
                return(HttpNotFound());
            }
            return(View(store));
        }
예제 #5
0
        public AutoForm GetView(object id, AutoBaseModel autoModel)
        {
            var autoForm = new AutoForm();

            var result = new MerchantStore();

            result.UserId = autoModel.BasicUser.Id;
            if (id == null)
            {
                var store = Resolve <IMerchantStoreService>().GetMerchantStore(autoModel.BasicUser.Id);
                if (store != null)
                {
                    result = store.FirstOrDefault();
                }
            }
            else
            {
                var store = Resolve <IMerchantStoreService>().GetMerchantStore(id.ConvertToLong());
                if (store != null)
                {
                    result = store.FirstOrDefault();
                }
            }

            if (result == null)
            {
                result = new MerchantStore();
            }

            autoForm = ToAutoForm(result);

            autoForm.Tooltip.AlertText      = "【店铺设置】主要针对于店铺名称、Logo、描述的设置。";
            autoForm.Tooltip.ButtomHelpText = new List <string>
            {
                "店铺名称:用于标识店铺主要信息;",
                "店铺Logo:主要用于上传图片,标识店铺图标",
                "店铺描述:对店铺进行详细性的信息描述"
            };

            return(autoForm);
        }
        // THông tin tài khoản
        public ActionResult Account(string id)
        {
            var                StoreId = db.MerchantStores.Where(x => x.User.Id == id).FirstOrDefault();
            var                user    = db.Users.Find(id);
            MerchantStore      store   = db.MerchantStores.Find(StoreId.Id);
            MerchantStoreModel model   = new MerchantStoreModel();

            model.MaCuaHang = store.Id;
            model.Address   = store.Address;
            model.BusinessRegistrationCode = store.BusinessRegistrationCode;
            model.TaxRegistrationCode      = store.TaxRegistrationCode;
            model.CardTradeNumber          = store.CardTradeNumber;
            model.CreditCardNumber         = store.CreditCardNumber;
            model.BankName       = store.BankName;
            model.createdDate    = store.createdDate;
            model.DeliveryMethod = store.DeliveryMethod;
            model.Name           = store.Name;
            model.Package        = store.Package;
            model.PhoneNumber    = store.PhoneNumber;
            model.Image1         = store.Image1;
            model.Image2         = store.Image2;
            model.Image3         = store.Image3;
            model.Image4         = store.Image4;
            model.Image5         = store.Image5;
            model.isDisabled     = store.isDisabled;
            model.User           = user;
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
        public ActionResult Account(MerchantStoreModel model)
        {
            MerchantStore store = db.MerchantStores.Find(model.MaCuaHang);

            model.User = db.Users.Find(model.User.Id);
            if (ModelState.IsValid)
            {
                store.Id      = model.MaCuaHang;
                store.Address = model.Address;
                store.BusinessRegistrationCode = model.BusinessRegistrationCode;
                store.TaxRegistrationCode      = model.TaxRegistrationCode;
                store.CardTradeNumber          = model.CardTradeNumber;
                store.CreditCardNumber         = model.CreditCardNumber;
                store.BankName       = model.BankName;
                store.createdDate    = model.createdDate;
                store.DeliveryMethod = model.DeliveryMethod;
                store.Name           = model.Name;
                store.Package        = model.Package;
                store.PhoneNumber    = model.PhoneNumber;
                store.Image1         = model.Image1;
                store.Image2         = model.Image2;
                store.Image3         = model.Image3;
                store.Image4         = model.Image4;
                store.Image5         = model.Image5;
                store.isDisabled     = model.isDisabled;
                store.User           = model.User;

                ViewBag.UserID = db.MerchantStores.FirstOrDefault(x => x.User.Id == store.User.Id);
                bool exists = System.IO.Directory.Exists(Server.MapPath("~/MerchantImages/" + ViewBag.UserID));

                if (!exists)
                {
                    System.IO.Directory.CreateDirectory(Server.MapPath("~/MerchantImages/" + ViewBag.UserID));
                }

                var f1 = Request.Files["Image1"];
                var f2 = Request.Files["Image2"];
                var f3 = Request.Files["Image3"];
                var f4 = Request.Files["Image4"];
                var f5 = Request.Files["Image5"];

                if (f1 != null && f1.ContentLength > 0)
                {
                    string fullPath = Request.MapPath(model.Image1);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    var path = Server.MapPath("~/MerchantImages/" + ViewBag.UserID + "/" + f1.FileName);
                    f1.SaveAs(path);
                    store.Image1 = "/MerchantImages/" + ViewBag.UserID + "/" + f1.FileName;
                }
                if (f2 != null && f2.ContentLength > 0)
                {
                    string fullPath = Request.MapPath(model.Image2);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    var path = Server.MapPath("~/MerchantImages/" + ViewBag.UserID + "/" + f2.FileName);
                    f2.SaveAs(path);
                    store.Image2 = "/MerchantImages/" + ViewBag.UserID + "/" + f2.FileName;
                }
                if (f3 != null && f3.ContentLength > 0)
                {
                    string fullPath = Request.MapPath(model.Image3);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    var path = Server.MapPath("~/MerchantImages/" + ViewBag.UserID + "/" + f3.FileName);
                    f3.SaveAs(path);
                    store.Image3 = "/MerchantImages/" + ViewBag.UserID + "/" + f3.FileName;
                }
                if (f4 != null && f4.ContentLength > 0)
                {
                    string fullPath = Request.MapPath(model.Image3);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    var path = Server.MapPath("~/MerchantImages/" + ViewBag.UserID + "/" + f4.FileName);
                    f4.SaveAs(path);
                    store.Image4 = "/MerchantImages/" + ViewBag.UserID + "/" + f4.FileName;
                }
                if (f5 != null && f5.ContentLength > 0)
                {
                    string fullPath = Request.MapPath(model.Image3);
                    if (System.IO.File.Exists(fullPath))
                    {
                        System.IO.File.Delete(fullPath);
                    }
                    var path = Server.MapPath("~/MerchantImages/" + ViewBag.UserID + "/" + f5.FileName);
                    f5.SaveAs(path);
                    store.Image5 = "/MerchantImages/" + ViewBag.UserID + "/" + f5.FileName;
                }

                db.Entry(store).State = EntityState.Modified;
                db.SaveChanges();

                return(RedirectToAction("Account", new { id = model.User.Id }));
            }

            return(View(model));
        }
예제 #8
0
        public ActionResult Register(MerchantStore model, string userid)
        {
            //var userManager = new UserManager<ApplicationUser>(new UserStore<ApplicationUser>(db));
            //var user_id = "";
            if (ModelState.IsValid)
            {
                //var email = Request.Form["email"];
                //var pass = Request.Form["pass"];
                //var user = new ApplicationUser { UserName = email, Email = email };
                //var result =  userManager.Create(user, pass);
                //if (result.Succeeded)
                //{
                //user_id = user.Id;
                MerchantStore store = new MerchantStore();
                store.User    = db.Users.FirstOrDefault(x => x.Id == userid);
                store.Name    = model.Name;
                store.Address = model.Address;
                store.BusinessRegistrationCode = model.BusinessRegistrationCode;
                store.TaxRegistrationCode      = model.TaxRegistrationCode;
                store.CardTradeNumber          = model.CardTradeNumber;
                store.CreditCardNumber         = model.CreditCardNumber;
                store.PhoneNumber    = model.PhoneNumber;
                store.DeliveryMethod = model.DeliveryMethod;
                store.createdDate    = DateTime.Now;
                store.BankName       = model.BankName;
                store.isDisabled     = false;

                var f  = Request.Files["Image1"];
                var f1 = Request.Files["Image2"];
                var f2 = Request.Files["Image3"];
                var f3 = Request.Files["Image4"];
                var f4 = Request.Files["Image5"];
                if (f != null && f.ContentLength > 0)
                {
                    var path = Server.MapPath("~/MerchantImages/" + f.FileName);
                    f.SaveAs(path);
                    store.Image1 = "/MerchantImages/" + f.FileName;
                }
                if (f1 != null && f1.ContentLength > 0)
                {
                    var path = Server.MapPath("~/MerchantImages/" + f1.FileName);
                    f1.SaveAs(path);
                    store.Image2 = "/MerchantImages/" + f1.FileName;
                }
                if (f2 != null && f2.ContentLength > 0)
                {
                    var path = Server.MapPath("~/MerchantImages/" + f2.FileName);
                    f2.SaveAs(path);
                    store.Image3 = "/MerchantImages/" + f2.FileName;
                }
                if (f3 != null && f3.ContentLength > 0)
                {
                    var path = Server.MapPath("~/MerchantImages/" + f3.FileName);
                    f3.SaveAs(path);
                    store.Image4 = "/MerchantImages/" + f3.FileName;
                }
                if (f4 != null && f4.ContentLength > 0)
                {
                    var path = Server.MapPath("~/MerchantImages/" + f4.FileName);
                    f4.SaveAs(path);
                    store.Image5 = "/MerchantImages/" + f4.FileName;
                }

                db.MerchantStores.Add(store);
                db.SaveChanges();
                return(RedirectToAction("Index", "Home"));
                //}
            }

            // If we got this far, something failed, redisplay form
            return(View());
        }