Exemplo n.º 1
0
 public ActionResult Create(Department newDepartment)
 {
     if (ModelState.IsValid)
     {
         db.Departments.Add(newDepartment);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newDepartment));
 }
Exemplo n.º 2
0
 public ActionResult Create(Category newCategory)
 {
     if (ModelState.IsValid)
     {
         db.Categories.Add(newCategory);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newCategory));
 }
Exemplo n.º 3
0
 public ActionResult Create(Employee newEmployee)
 {
     if (ModelState.IsValid)
     {
         db.Employees.Add(newEmployee);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newEmployee));
 }
Exemplo n.º 4
0
 public ActionResult Create(Customer newCustomer)
 {
     if (ModelState.IsValid)
     {
         db.Customers.Add(newCustomer);
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(newCustomer));
 }
Exemplo n.º 5
0
        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));
        }
Exemplo n.º 6
0
 public ActionResult UserRegister(User newUser)
 {
     if (ModelState.IsValid)
     {
         db.Users.Add(newUser);
         db.SaveChanges();
         return(RedirectToAction("Index", "Login"));
     }
     return(View(newUser));
 }
Exemplo n.º 7
0
 public int Add(Comment comment)
 {
     context.Comments.Add(comment);
     context.SaveChanges();
     return(1);
 }
Exemplo n.º 8
0
 public int Add(Cart newCart)
 {
     context.Carts.Add(newCart);
     context.SaveChanges();
     return(1);
 }