예제 #1
0
        public async Task <IActionResult> Create([Bind("ServicedStoreId,Name,Address,PhoneNumber")] ServicedStore servicedStore)
        {
            if (ModelState.IsValid)
            {
                _context.Add(servicedStore);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(servicedStore));
        }
        public async Task <IActionResult> Create([Bind("PostId,Name,Money")] Post post)
        {
            if (ModelState.IsValid)
            {
                _context.Add(post);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(post));
        }
        public async Task <IActionResult> Create([Bind("TypeOfFaultId,RepairedModelId,Name,MethodRepair,WorkPrice")] TypeOfFault typeOfFault)
        {
            if (ModelState.IsValid)
            {
                _context.Add(typeOfFault);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", typeOfFault.RepairedModelId);
            return(View(typeOfFault));
        }
        public async Task <IActionResult> Create([Bind("EmployeeId,FullName,Experience,PostId")] Employee employee)
        {
            if (ModelState.IsValid)
            {
                _context.Add(employee);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PostId"] = new SelectList(_context.Posts, "PostId", "Name", employee.PostId);
            return(View(employee));
        }
        public async Task <IActionResult> Create([Bind("SparePartId,Name,Functions,Price,RepairedModelId,TypeOfFaultId")] SparePart sparePart)
        {
            if (ModelState.IsValid)
            {
                _context.Add(sparePart);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", sparePart.RepairedModelId);
            ViewData["TypeOfFaultId"]   = new SelectList(_context.TypeOfFaults, "TypeOfFaultId", "Name", sparePart.TypeOfFaultId);
            return(View(sparePart));
        }
        public async Task <IActionResult> Create([Bind("RepairedModelId,Name,Type,Manufacturer," +
                                                       "TechSpecification,Features")] RepairedModel repairedModel)
        {
            if (ModelState.IsValid)
            {
                _context.Add(repairedModel);
                await Task.Run(() =>
                {
                    _context.SaveChangesAsync();
                    _cachingModel.RefreshCache(KEY_CACHE);
                });

                return(RedirectToAction(nameof(Index)));
            }
            return(View(repairedModel));
        }
예제 #7
0
        public async Task <IActionResult> Create([Bind("OrderId,DateOrder,ReturnDate,FullNameCustumer,RepairedModelId," +
                                                       "TypeOfFaultId,ServicedStoreId,GuaranteeMark,GuaranteePeriod,EmployeeId")] Order order)
        {
            order.Price = (double)_context.TypeOfFaults.Where(t => t.TypeOfFaultId == order.TypeOfFaultId)
                          .Select(t => t.WorkPrice)
                          .FirstOrDefault();
            if (ModelState.IsValid)
            {
                _context.Add(order);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["EmployeeId"]      = new SelectList(_context.Employees, "EmployeeId", "FullName", order.EmployeeId);
            ViewData["RepairedModelId"] = new SelectList(_context.RepairedModels, "RepairedModelId", "Name", order.RepairedModelId);
            ViewData["ServicedStoreId"] = new SelectList(_context.ServicedStores, "ServicedStoreId", "Name", order.ServicedStoreId);
            ViewData["TypeOfFaultId"]   = new SelectList(_context.TypeOfFaults, "TypeOfFaultId", "Name", order.TypeOfFaultId);
            return(View(order));
        }