public ActionResult TaoMoi(PRODUCT sp, HttpPostedFileBase ShowImage) { //load list mã sản phẩm ViewBag.CategoryID = new SelectList(db.CATEGORies.OrderBy(n => n.CategoryID), "CategoryID", "CategoryName"); // kiểm tra hình ảnh đã tồn tại hay chưa if (ShowImage.ContentLength > 0) { //lấy tên hình ảnh var filename = Path.GetFileName(ShowImage.FileName); //lấy hình ảnh chuyển đến thư mục hình ảnh var path = Path.Combine(Server.MapPath("~/Content/HinhAnhSP"), filename); //nếu thư mục đã có hình ảnh thì xuất ra thông báo if (System.IO.File.Exists(path)) { ViewBag.upload = "Hình Đã Tồn Tại "; return(View()); } else { //lấy hình ảnh đưa ra thư mục Hình Ảnh Sản Phẩm ShowImage.SaveAs(path); sp.ShowImage = filename; } } db.PRODUCTs.Add(sp); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Create([Bind(Include = "MaNV,HoTen,NgaySinh,SDT,ViTri,LuongCoBan")] NhanVien nhanVien) { if (ModelState.IsValid) { db.NhanViens.Add(nhanVien); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(nhanVien)); }
public ActionResult Create([Bind(Include = "PersonID,Personusername,PersonPassword,PersonEmail,PersonName,PersonPhone,PersonAdress,CreatedDate")] PERSON pERSON) { if (ModelState.IsValid) { db.People.Add(pERSON); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(pERSON)); }
public ActionResult Create([Bind(Include = "ResourcesID,Resourcesname,Quantity,Total")] RESOURCE rESOURCE) { if (ModelState.IsValid) { db.RESOURCES.Add(rESOURCE); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(rESOURCE)); }
public ActionResult Create([Bind(Include = "CustomerID,CustomerUsername,CustomerPassword,CustomerEmail,CustomerName,CustomerPhone,CustomerAdress,CreatedDate")] CUSTOMER cUSTOMER) { if (ModelState.IsValid) { db.CUSTOMERs.Add(cUSTOMER); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(cUSTOMER)); }
public IActionResult Post([FromBody] ReservationModel reservation) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _cafeDbContext.Reservations.Add(reservation); _cafeDbContext.SaveChanges(); return(StatusCode(StatusCodes.Status201Created)); }
public AbrirNovaMesaCommandResult Handle(AbrirNovaMesaCommand c) { try { using (var _context = new CafeDbContext()) { if (Validacao(c.NumMesa)) { var table = new TbTabOpened { NuTable = c.NumMesa, IdWaiter = c.GarcomId, StActive = c.Ativo, DtService = c.DataServico, StUniqueIdentifier = Guid.NewGuid() }; _context.TbTabOpened.Add(table); var id = _context.SaveChanges(); return(_context.TbTabOpened .AsNoTracking() .AsParallel() .Where(x => x.Id == table.Id) .Select(o => new AbrirNovaMesaCommandResult(o.Id, o.NuTable.Value, o.IdWaiter.Value, o.StActive, o.DtService.Value)) .FirstOrDefault()); } else { throw new Exception("Essa mesa já está aberta"); } } } catch (Exception ex) { throw ex; } }
public void Add(Category category) { _context.Categories.Add(category); _context.SaveChanges(); }
public Cafe CreateCafe(Cafe cafe) { _cafeDbContext.Cafes.Add(cafe); _cafeDbContext.SaveChanges(); return(cafe); }
public void Add(ClientProduct sale) { sale.Date = DateTime.Now; _context.Sales.Add(sale); _context.SaveChanges(); }
public void Add(Product product) { _context.Products.Add(product); _context.SaveChanges(); }
public void Add(Client client) { client.TimeOfComing = DateTime.Now; _context.Clients.Add(client); _context.SaveChanges(); }
public void Add(Client client) { _context.Clients.Add(client); _context.SaveChanges(); }
public long Insert(USER entity) //Thêm mới user { db.USERs.Add(entity); db.SaveChanges(); return(entity.UserId); }