예제 #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);
        }
예제 #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)); }
                                                      }
예제 #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);
 }
예제 #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));
 }