Ejemplo n.º 1
0
        public void Create_WithValidData_SavesRecordInTheDatabase()
        {
            // Arrange
            var newFoodItem = sut.Create(foodItem);

            // Assert
            Assert.IsNotNull(newFoodItem);
            Assert.IsTrue(newFoodItem.FoodId != null);

            // CleanUp
            sut.Delete(foodItem.FoodId);
        }
Ejemplo n.º 2
0
                                                      [Authorize] public async Task <IHttpActionResult> Create([FromBody] MenuItem model)
                                                      {
                                                          if (!ModelState.IsValid)
                                                          {
                                                              return(BadRequest(ModelState));
                                                          }

                                                          try { log.Info(new MDCSet(this.ControllerContext.RouteData));
                                                                await _entityRepo.Create(model);

                                                                return(Ok("Registro creado exitosamente!")); }
                                                          catch (Exception e) { log.Error(new MDCSet(this.ControllerContext.RouteData), e);
                                                                                return(InternalServerError(e)); }
                                                      }
Ejemplo n.º 3
0
 public ActionResult AddMenuItem(MenuItemViewModel model)
 {
     if (ModelState.IsValid)
     {
         MenuItemRepository inventoryRepository = new MenuItemRepository(new ApplicationDbContext());
         string customerId = null;
         var firstOrDefault = new ApplicationDbContext().Users.FirstOrDefault(cus => cus.UserName == User.Identity.Name);
         if (firstOrDefault !=
             null)
         {
             customerId = firstOrDefault.Id;
         }
         model.CustomerId = customerId;
         model.IsActive = true;
         inventoryRepository.Create(model);
         return RedirectToAction("MenuItems");
     }
     return View(model);
 }
Ejemplo n.º 4
0
 public ActionResult AddMenuItem(MenuItemViewModel model)
 {
     if (ModelState.IsValid)
     {
         MenuItemRepository inventoryRepository = new MenuItemRepository(new ApplicationDbContext());
         string             customerId          = null;
         var firstOrDefault = new ApplicationDbContext().Users.FirstOrDefault(cus => cus.UserName == User.Identity.Name);
         if (firstOrDefault !=
             null)
         {
             customerId = firstOrDefault.Id;
         }
         model.CustomerId = customerId;
         model.IsActive   = true;
         inventoryRepository.Create(model);
         return(RedirectToAction("MenuItems"));
     }
     return(View(model));
 }