示例#1
0
        public object Store()
        {
            string Type        = HttpContext.Current.Request.Form["Type"];
            string Fullname    = HttpContext.Current.Request.Form["Fullname"];
            string Email       = HttpContext.Current.Request.Form["Email"];
            string Address     = HttpContext.Current.Request.Form["Address"];
            string PhoneNumber = HttpContext.Current.Request.Form["PhoneNumber"];
            string Mobile      = HttpContext.Current.Request.Form["Mobile"];
            string PostalCode  = HttpContext.Current.Request.Form["PostalCode"];
            string Desc        = HttpContext.Current.Request.Form["Desc"];

            int type = Convert.ToInt32(Type);

            if (type < 1 || type > 4)
            {
                return(new { Message = 1 });
            }
            WholeSaler w = new Models.WholeSaler();

            w.Address    = Address;
            w.Desc       = Desc;
            w.Fullname   = Fullname;
            w.Mobile     = Mobile;
            w.Phone      = PhoneNumber;
            w.PostalCode = PostalCode;
            w.Type       = type;
            DBContext db = new DBContext();

            db.WholeSalers.Add(w);
            db.SaveChanges();
            return(new { Message = 0 });
        }
示例#2
0
        public ActionResult Store()
        {
            string Type        = Request["Type"];
            string Fullname    = Request["Fullname"];
            string Password    = Request["Password"];
            string Email       = Request["Email"];
            string Address     = Request["Address"];
            string PhoneNumber = Request["PhoneNumber"];
            string Mobile      = Request["Mobile"];
            string PostalCode  = Request["PostalCode"];
            string Desc        = Request["Desc"];

            int type = Convert.ToInt32(Type);

            if (type < 1 || type > 4)
            {
                ModelState.AddModelError("", "نوع کاربر را انتخاب کنید");
                return(View("Index"));
            }
            WholeSaler w = new Models.WholeSaler();

            w.Address    = Address;
            w.Desc       = Desc;
            w.Fullname   = Fullname;
            w.Mobile     = Mobile;
            w.Phone      = PhoneNumber;
            w.PostalCode = PostalCode;
            w.Type       = type;
            w.IsShow     = false;
            DBContext db = new DBContext();

            db.WholeSalers.Add(w);
            db.SaveChanges();
            ViewBag.Message = "user";
            return(View("Index"));
        }