Beispiel #1
0
 public ActionResult Create(Department newDepartment)
 {
     if (ModelState.IsValid)
     {
         db.Departments.Add(newDepartment);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newDepartment));
 }
 public ActionResult Create(Category newCategory)
 {
     if (ModelState.IsValid)
     {
         db.Categories.Add(newCategory);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newCategory));
 }
Beispiel #3
0
 public ActionResult Create(Employee newEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Employees.Add(newEmployee);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newEmployee));
 }
 public ActionResult Create(Customer newCustomer)
 {
     if (ModelState.IsValid)
     {
         db.Customers.Add(newCustomer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newCustomer));
 }
        public ActionResult Create(Product newProduct)
        {
            if (ModelState.IsValid)
            {
                string _fileName  = Path.GetFileNameWithoutExtension(newProduct.FilePhoto.FileName);
                string _extension = Path.GetExtension(newProduct.FilePhoto.FileName);
                _fileName           = _fileName + DateTime.Now.ToString("yyMMddhhmmssfff") + _extension;
                newProduct.ImageUrl = _fileName;

                _fileName = Path.Combine(Server.MapPath("~/Uploads/ProductImages/") + _fileName);
                newProduct.FilePhoto.SaveAs(_fileName);

                db.Products.Add(newProduct);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(newProduct));
        }
Beispiel #6
0
 public ActionResult UserRegister(User newUser)
 {
     if (ModelState.IsValid)
     {
         db.Users.Add(newUser);
         db.SaveChanges();
         return(RedirectToAction("Index", "Login"));
     }
     return(View(newUser));
 }
Beispiel #7
0
 public int Add(Comment comment)
 {
     context.Comments.Add(comment);
     context.SaveChanges();
     return(1);
 }
Beispiel #8
0
 public int Add(Cart newCart)
 {
     context.Carts.Add(newCart);
     context.SaveChanges();
     return(1);
 }