Example #1
0
        public async Task <IActionResult> PutExport(int id, Export export)
        {
            if (id != export.dataID)
            {
                return(BadRequest());
            }

            _context.Entry(export).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ExportExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public async Task <IActionResult> Create([Bind("Name,Id,CreatedDate,ModifiedDate")] Stock stock)
        {
            if (ModelState.IsValid)
            {
                stock.CreatedDate = stock.ModifiedDate = DateTime.Now.ToUniversalTime();
                _context.Add(stock);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(stock));
        }
Example #3
0
        public async Task <IActionResult> Create([Bind("Name,ParentId,Id,CreatedDate,ModifiedDate")] Category category)
        {
            if (ModelState.IsValid)
            {
                category.CreatedDate = category.ModifiedDate = DateTime.UtcNow;
                _context.Add(category);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(category));
        }
        public async Task <IActionResult> Create([Bind("ShortName,FullName,Id,CreatedDate,ModifiedDate")] Brand brand)
        {
            if (ModelState.IsValid)
            {
                brand.ModifiedDate = brand.CreatedDate = DateTime.Now.ToUniversalTime();
                _context.Add(brand);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(brand));
        }
Example #5
0
        public async Task <IActionResult> Create([Bind("CategoryId,ProductId")] ProductCategory productCategory)
        {
            if (ModelState.IsValid)
            {
                _context.Add(productCategory);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryId"] = new SelectList(_context.Categories, "Id", "Name", productCategory.Category.Name);
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "Name", productCategory.Product.Name);
            return(View(productCategory));
        }
        public async Task <IActionResult> Create([Bind("Url,ProductId,Id,CreatedDate,ModifiedDate,ImageFile")] Image image)
        {
            if (ModelState.IsValid)
            {
                var product = _context.Products.Find(image.ProductId);
                image.Url = await _commonServices.CreateImage(image.ImageFile, image.Url, "/images/Products/" + product.Name);

                image.CreatedDate = image.ModifiedDate = DateTime.UtcNow;
                _context.Add(image);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "DisplayName", image.Product.DisplayName);
            return(View(image));
        }
        public async Task <IActionResult> Create([Bind("FirstName,LastName,Phone,Email,Username,Password,Note,Age,Gender,Address,City,UserType,SubsidiaryTotalProduct,AgentName,SupplyCode,ImageFile,SupplyName,Salary,Id,CreatedDate,ModifiedDate")] User user)
        {
            if (ModelState.IsValid)
            {
                //Save image to wwwroot/image
                //string wwwRootPath = _hostEnvironment.WebRootPath;
                //string fileName = Path.GetFileNameWithoutExtension(user.ImageFile.FileName);
                //string extension = Path.GetExtension(user.ImageFile.FileName);
                user.Avatar = await _commonServices.CreateImage(user.ImageFile, user.Avatar, "/images/People");

                //Insert record
                user.CreatedDate = user.ModifiedDate = DateTime.Now.ToUniversalTime();
                _context.Add(user);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(user));
        }
 public async Task Commit()
 {
     await _context.SaveChangesAsync();
 }