Пример #1
0
        public async Task <IActionResult> Edit(Guid id, [Bind("Id,WorkShopId,LocationCode,LocationName,Address,Email,ContactPerson,MobileNumber,CreatedOn")] WorkShopLocation workShopLocation)
        {
            if (id != workShopLocation.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(workShopLocation);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WorkShopLocationExists(workShopLocation.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorkShopId"] = new SelectList(_context.WorkShop, "Id", "WorkShopName", workShopLocation.WorkShopId);
            return(View(workShopLocation));
        }
Пример #2
0
        public async Task <IActionResult> Create([Bind("Id,WorkShopId,LocationCode,LocationName,Address,Email,ContactPerson,MobileNumber,CreatedOn")] WorkShopLocation workShopLocation)
        {
            if (ModelState.IsValid)
            {
                workShopLocation.Id = Guid.NewGuid();
                _context.Add(workShopLocation);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WorkShopId"] = new SelectList(_context.WorkShop, "Id", "WorkShopName", workShopLocation.WorkShopId);
            return(View(workShopLocation));
        }