Exemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,Username,Pass")] Login login)
        {
            if (id != login.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(login);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!LoginExists(login.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(login));
        }
Exemplo n.º 2
0
        public async Task <IActionResult> AddIncidentManual([Bind("ID,Iname,Category,Description,Solution,Images,Videos,Date,Status,Count")] Incident incident, List <IFormFile> Images, List <IFormFile> Videos)
        {
            var currentIncidentID = await _context.Incident
                                    .OrderByDescending(m => m.ID)
                                    .FirstOrDefaultAsync();

            var ciID = currentIncidentID.ID + 1;
            var IID  = HttpContext.Session.GetString("ManualID");

            foreach (var item in Images)
            {
                if (item.Length > 0)
                {
                    using (var stream = new MemoryStream())
                    {
                        await item.CopyToAsync(stream);

                        incident.Images = stream.ToArray();
                    }
                }
            }

            foreach (var item in Videos)
            {
                if (item.Length > 0)
                {
                    using (var stream1 = new MemoryStream())
                    {
                        await item.CopyToAsync(stream1);

                        incident.Videos = stream1.ToArray();
                    }
                }
            }

            if (ModelState.IsValid)
            {
                incident.ID = ciID;
                DateTime.Now.Date.ToString("MM / dd / yyyy");
                _context.Add(incident);
                await _context.SaveChangesAsync();


                var incidentss = await _context.IncidentTask
                                 .FirstOrDefaultAsync((m => m.ID.ToString() == HttpContext.Session.GetString("ManualID")));

                if (incidentss != null)
                {
                    incidentss.IID  = ciID;
                    incidentss.Eway = "Auto";
                    _context.Update(incidentss);
                    await _context.SaveChangesAsync();
                }

                return(RedirectToAction(nameof(Index)));
            }

            return(View(incident));
        }
Exemplo n.º 3
0
        public async Task <IActionResult> Create([Bind("Id,ProductName,PartNumber,ProductLabel,StartingInventory,InventoryReceived,InventoryShipped,InventoryOnHand,MinimumRequired")] Products products)
        {
            if (ModelState.IsValid)
            {
                _context.Add(products);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(products));
        }
Exemplo n.º 4
0
        public async Task <IActionResult> Create([Bind("Id,Supplier")] Suppliers suppliers)
        {
            if (ModelState.IsValid)
            {
                _context.Add(suppliers);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(suppliers));
        }
Exemplo n.º 5
0
        public async Task <IActionResult> Create([Bind("Id,Title,First,Middle,Last,ProductId,NumberShipped,OrderDate")] Orders orders)
        {
            if (ModelState.IsValid)
            {
                _context.Add(orders);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(orders));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Create([Bind("Id,SupplierId,ProductId,NumberReceived,PurchaseDate")] Purchases purchases)
        {
            if (ModelState.IsValid)
            {
                _context.Add(purchases);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]  = new SelectList(_context.Products, "Id", "ProductName", purchases.ProductId);
            ViewData["SupplierId"] = new SelectList(_context.Suppliers, "Id", "Supplier", purchases.SupplierId);
            return(View(purchases));
        }
        public async Task <Domain.Categories.Category> Insert(Domain.Categories.Category category)
        {
            if (category == null)
            {
                throw new ArgumentNullException(nameof(category));
            }

            var dbCategory = category.ToDalOrNull(CategoryConverter.ToDalNew);

            await _categories.AddAsync(dbCategory);

            await context.SaveChangesAsync();

            return(dbCategory.ToDomainOrNull(CategoryConverter.ToDomain));
        }
Exemplo n.º 8
0
        public async Task <IActionResult> Create([Bind("ID,Sname,IC,Designation,Gender,DOB,Address,Postcode,City,State,Country,MobileNo,Email,Role,Floor,Department,TableNo,Status,Spoint,JoinedDate,Username,Pass")] Staff staff)
        {
            Boolean Validate     = true;
            var     userToVerify = await _context.Staff.SingleOrDefaultAsync(s => s.Username == staff.Username);

            if (userToVerify != null)
            {
                Validate = true;
            }
            else
            {
                Validate = false;
            }
            if (Validate)
            {
                ModelState.AddModelError("Error", "Username Already Exits");
                return(View());
            }
            else if (ModelState.IsValid)
            {
                staff.JoinedDate = DateTime.Now.Date;
                DateTime.Now.Date.ToString("MM / dd / yyyy");
                _context.Add(staff);
                await _context.SaveChangesAsync();

                ViewBag.StaffID   = HttpContext.Session.GetString("StaffID");
                ViewBag.StaffName = HttpContext.Session.GetString("StaffName");
                ViewBag.StaffRole = HttpContext.Session.GetString("StaffRole");

                //TempData["ID"] = staffDetail.ID;
                //TempData["Name"] = staffDetail.Sname;
                //TempData["Role"] = staffDetail.Role;

                return(RedirectToAction("Index", "Staffs"));
            }
            return(View(staff));
        }
Exemplo n.º 9
0
        public async Task <bool> Update(Domain.Items.Item item)
        {
            if (item == null)
            {
                throw new ArgumentNullException(nameof(item));
            }

            var dbItem = await _items
                         .Where(i => i.Id == item.Id)
                         .SingleOrDefaultAsync();

            if (dbItem == null)
            {
                return(false);
            }

            dbItem.SellPrice  = item.SellPrice;
            dbItem.StockPrice = item.StockPrice;
            dbItem.Stock      = item.Stock;

            await context.SaveChangesAsync();

            return(true);
        }