Exemplo n.º 1
0
        private Task UpdateCategoryAsync(CategoryDto category, Category categoryDomain)
        {
            _mapper.Map <CategoryDto, Category>(category, categoryDomain);

            _context.Update(categoryDomain);

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        //Denne her er kun til at update PaymentCondition og employee, indtil videre
        //TODO add so it handles change in food (update food).
        public OrderDTO Update(OrderDTO obj, bool transactionEndpoint = true)
        {
            if (!RestaurantOrder.Validate(obj))
            {
                throw new ValidationException("Bad input");
            }
            if (transactionEndpoint)
            {
                _context.Database.BeginTransaction(IsolationLevel.Serializable);
            }
            try
            {
                var tempOrder = Converter.Convert(obj);

                var order = _context.RestaurantOrder
                            .Where(o => o.OrderNo == obj.OrderNo)
                            .Include(f => f.OrderLine)
                            .ThenInclude(f => f.Food)
                            .ThenInclude(f => f.Price)
                            .Include(f => f.OrderLine)
                            .ThenInclude(f => f.Food.FoodCategory)
                            .Include(e => e.Employee)
                            .ThenInclude(e => e.Person)
                            .ThenInclude(e => e.Location)
                            .ThenInclude(e => e.ZipCodeNavigation)
                            .Include(e => e.Employee.Title)
                            .Include(r => r.Reservation)
                            .Include(pc => pc.PaymentCondition).OrderBy(x => x.OrderDate).FirstOrDefault();

                order.EmployeeId = tempOrder.EmployeeId;

                order.PaymentConditionId = tempOrder.PaymentConditionId;
                _context.Update(order);

                if (transactionEndpoint)
                {
                    _context.SaveChanges();
                    _context.Database.CommitTransaction();
                    return(GetById(order.OrderNo));
                }
            }
            catch (Exception)
            {
                _context.Database.RollbackTransaction();
                throw;
            }

            return(null);
        }
        public IActionResult ReviewEditForm(int?id, Review reviewEntry)
        {
            if (ModelState.IsValid)
            {
                reviewEntry.UserId     = (int)HttpContext.Session.GetInt32("userID");
                reviewEntry.ReviewDate = DateTime.Now;
                _context.Update(reviewEntry);
                _context.SaveChanges();

                return(Redirect("/User/ReviewsPage"));
            }

            ViewData["Rating"] = new SelectList(Review.digits, "Value", "Text");
            return(View(reviewEntry));
        }
        public async Task <IActionResult> Edit(int id, [Bind("PlateID,Name,Ingredients,Price")] Plate plate)
        {
            if (id != plate.PlateID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(plate);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!PlateExists(plate.PlateID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(plate));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id_restaurante,Nombre,Descripcion,Direccion,H_apertura,H_cierre,Logo,Imagen_item")] tbl_Restaurantes tbl_Restaurantes)
        {
            if (id != tbl_Restaurantes.Id_restaurante)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbl_Restaurantes);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tbl_RestaurantesExists(tbl_Restaurantes.Id_restaurante))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbl_Restaurantes));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Amount,ProductId,DishId")] Using @using)
        {
            if (id != @using.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(@using);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!UsingExists(@using.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(View(_context.Usings.ToListAsync()));
            }
            ViewData["ProductId"] = new SelectList(_context.Products, "Id", "Id", @using.ProductId);
            ViewData["DishId"]    = new SelectList(_context.Dishes, "Id", "Name", @using.DishId);

            return(View(@using));
        }
Exemplo n.º 7
0
        public async Task <IActionResult> Edit(string id, [Bind("Name,Type,Address,RestaurantID")] Restaurant restaurant)
        {
            if (id != restaurant.RestaurantID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(restaurant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RestaurantExists(restaurant.RestaurantID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurant));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id_rol,Rol,Descripcion")] tbl_Roles tbl_Roles)
        {
            if (id != tbl_Roles.Id_rol)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbl_Roles);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tbl_RolesExists(tbl_Roles.Id_rol))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbl_Roles));
        }
Exemplo n.º 9
0
        public async Task <IActionResult> Edit(int id, [Bind("Id_dato,Nombre,Apellido,Direccion,Eliminacion")] tbl_Datos tbl_Datos)
        {
            if (id != tbl_Datos.Id_dato)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbl_Datos);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tbl_DatosExists(tbl_Datos.Id_dato))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbl_Datos));
        }
Exemplo n.º 10
0
        public async Task <IActionResult> Edit(int id, [Bind("ProductName,Description,ImagePath,UnitPrice,CategoryID")] Product product)
        {
            if (id != product.ProductID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.ProductID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CategoryID"] = new SelectList(_context.Categories, "CategoryID", "CategoryName", product.CategoryID);
            return(View(product));
        }
Exemplo n.º 11
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Image,Name,Type,Weight,Price,Remarks,RestaurantId")] Dish dish)
        {
            if (id != dish.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(dish);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DishExists(dish.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Name", dish.RestaurantId);
            return(View(dish));
        }
        public async Task <IActionResult> Edit(int id, [Bind("Id_usuario,Id_dato,Id_rol,Usuario,Clave,Estado")] tbl_Usuarios tbl_Usuarios)
        {
            if (id != tbl_Usuarios.Id_usuario)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tbl_Usuarios);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!tbl_UsuariosExists(tbl_Usuarios.Id_usuario))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tbl_Usuarios));
        }
        public async Task <IActionResult> Edit(int id, [Bind("ID,Name,Address,City,State,Phone,OwnerName,RegistrationDate")] Restaurant restaurant)
        {
            if (id != restaurant.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(restaurant);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!RestaurantExists(restaurant.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(restaurant));
        }
        public IActionResult EditMenuEntryForm(int?id, MenuEntry menuEntry)
        {
            if (id != menuEntry.MenuEntryId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    var menu = _context.Menus.Find(menuEntry.MenuId);
                    menu.Changed      = DateTime.Now;
                    menuEntry.Changed = DateTime.Now;
                    _context.Update(menuEntry);
                    _context.SaveChanges();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!MenuEntryExists(menuEntry.MenuEntryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Redirect("/User/FoodMenu"));
            }

            ViewData["MenuId"] = new SelectList(_context.Menus, "MenuId", "Title", menuEntry.MenuId);
            return(View(menuEntry));
        }
Exemplo n.º 15
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,Address,Phone")] Provider provider)
        {
            if (id != provider.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(provider);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProviderExists(provider.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(provider));
        }
Exemplo n.º 16
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Name,QuantityAvailabale,BestBefore")] Product product)
        {
            if (id != product.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(product);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ProductExists(product.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
Exemplo n.º 17
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Image,Name,Surname,Phone,Position,DateOfBirth,Salary,HomeAddress,RestaurantId")] Employee employee)
        {
            if (id != employee.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(employee);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!EmployeeExists(employee.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Address", employee.RestaurantId);
            return(View(employee));
        }
Exemplo n.º 18
0
        public long UpdateRestaurant(long id, UpdateRestaurantRequest updateRestaurant)
        {
            var restaurant = context.Restaurants.FirstOrDefault(x => x.Id == id);

            restaurant.Adress = updateRestaurant.Adress;
            restaurant.City   = updateRestaurant.City;
            context.Update(restaurant);
            context.SaveChanges();
            return(restaurant.Id);
        }
Exemplo n.º 19
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Date,Price,Amount,ProviderId,ProductId,RestaurantId,Status,PlanReturn,FactReturn")] Order order)
        {
            if (id != order.Id)
            {
                return(NotFound());
            }
            var todayDate = DateTime.Now;

            if (order.Date > todayDate)
            {
                ModelState.AddModelError("Date", "Некорректна дата");
            }
            if (order.PlanReturn < order.Date)
            {
                ModelState.AddModelError("PlanReturn", "Некорректна дата повернення");
            }
            if (order.Amount <= 0)
            {
                ModelState.AddModelError("Amount", "Некорректна кількість");
            }
            if (order.Price < 0)
            {
                ModelState.AddModelError("Price", "Некорректна вартість");
            }


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(order);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OrderExists(order.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["ProductId"]    = new SelectList(_context.Products, "Id", "Id", order.ProductId);
            ViewData["ProviderId"]   = new SelectList(_context.Providers, "Id", "Address", order.ProviderId);
            ViewData["RestaurantId"] = new SelectList(_context.Restaurants, "Id", "Address", order.RestaurantId);
            return(View(order));
        }
Exemplo n.º 20
0
        //  dish.RestaurantId =restaurantId;



        // POST: Dishes/Edit/5
        // To protect from overposting attacks, enable the specific properties you want to bind to.
        // For more details, see http://go.microsoft.com/fwlink/?LinkId=317598.

        public async Task <ActionResult <Dish> > Edit(int id, Dish dish)
        {
            try
            {
                _context.Update(dish);
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                throw;
            }

            return(dish);
        }
Exemplo n.º 21
0
        public async Task <Restaurant> UpdateRating(int v1, short value)
        {
            using (var dbContext = new RestaurantContext())
            {
                var updtRecord = (from r in dbContext.Restaurants where r.RestaurantId == v1 select r).SingleOrDefault();
                if (updtRecord != null)
                {
                    updtRecord.Ratings = value;
                    dbContext.Update(updtRecord);
                    await dbContext.SaveChangesAsync();

                    return(updtRecord);
                }
                return(null);
            }
        }
Exemplo n.º 22
0
        public IActionResult OrderDeleteForm(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            var order = _context.Orders.Find(id);

            if (order == null)
            {
                return(NotFound());
            }

            order.State = (int)OrderState.Canceled;
            _context.Update(order);
            _context.SaveChanges();

            return(RedirectToAction("OrderList"));
        }
Exemplo n.º 23
0
 public async Task UpdateRestaurant(Restaurant restaurant)
 {
     _restaurantContext.Update(restaurant);
     await _restaurantContext.SaveChangesAsync();
 }
Exemplo n.º 24
0
 public async Task Update(Restaurant entity)
 {
     _repository.Update(entity);
     await _repository.SaveChangesAsync();
 }
 public async Task Update(Order entity)
 {
     _repository.Update(entity);
     await _repository.SaveChangesAsync();
 }
 public async void editRestaurant(Restaurant restaurant)
 {
     _context.Database.EnsureCreated();
     _context.Update(restaurant);
     await _context.SaveChangesAsync();
 }