コード例 #1
0
ファイル: ProductController.cs プロジェクト: thuccd/TTCSDL_01
        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"));
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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));
        }
コード例 #4
0
        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));
        }
コード例 #5
0
        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));
        }
コード例 #6
0
        public IActionResult Post([FromBody] ReservationModel reservation)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            _cafeDbContext.Reservations.Add(reservation);
            _cafeDbContext.SaveChanges();
            return(StatusCode(StatusCodes.Status201Created));
        }
コード例 #7
0
        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;
            }
        }
コード例 #8
0
 public void Add(Category category)
 {
     _context.Categories.Add(category);
     _context.SaveChanges();
 }
コード例 #9
0
 public Cafe CreateCafe(Cafe cafe)
 {
     _cafeDbContext.Cafes.Add(cafe);
     _cafeDbContext.SaveChanges();
     return(cafe);
 }
コード例 #10
0
 public void Add(ClientProduct sale)
 {
     sale.Date = DateTime.Now;
     _context.Sales.Add(sale);
     _context.SaveChanges();
 }
コード例 #11
0
 public void Add(Product product)
 {
     _context.Products.Add(product);
     _context.SaveChanges();
 }
コード例 #12
0
 public void Add(Client client)
 {
     client.TimeOfComing = DateTime.Now;
     _context.Clients.Add(client);
     _context.SaveChanges();
 }
コード例 #13
0
 public void Add(Client client)
 {
     _context.Clients.Add(client);
     _context.SaveChanges();
 }
コード例 #14
0
ファイル: UserDao.cs プロジェクト: thuccd/TTCSDL_01
 public long Insert(USER entity) //Thêm mới user
 {
     db.USERs.Add(entity);
     db.SaveChanges();
     return(entity.UserId);
 }