public IActionResult CreateWidget(string name)
        {
            Models.Widget widget = new Models.Widget();
            widget.Name = name;
            db.CreateWidget(widget);

            return(new ObjectResult(widget));
        }
예제 #2
0
 public async Task SaveWidget(Widget widget)
 {
     using (var db = new AppDbContext())
     {
         db.Widgets.Add(widget);
         await db.SaveChangesAsync();
     }
 }
예제 #3
0
        public Guid CreateWidget(string name, float price, Guid userId)
        {
            var user = _repoU.GetUser(userId);
            var widget = new Widget()
            {
                Name = name,
                Price = price,
                User = user
            };

            _repoW.SaveWidget(widget);
            return widget.Id;
        }
예제 #4
0
 public ActionResult Create(Widget newWidget)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _case.CreateWidget(newWidget.Name, newWidget.Price);
             return RedirectToAction("Index");
         }
         else
         {
             return View(newWidget);
         }
     }
     catch
     {
         return View(newWidget);
     }
 }
예제 #5
0
 public ActionResult Create(Widget newWidget)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _case.CreateWidget(newWidget.Name, newWidget.Price, newWidget.User.Id);
             return RedirectToAction("Index");
         }
         else
         {
             return View(newWidget);
         }
     }
     catch (Exception e)
     {
         _log.Error(e.Message);
         return View(newWidget);
     }
 }
예제 #6
0
 public void UpdateWidget(Widget widget)
 {
     _repo.SaveWidget(widget);
 }
예제 #7
0
 public Guid CreateWidget(string name, float price)
 {
     var w = new Widget {Name = name, Price = price};
     _repo.SaveWidget(w);
     return w.Id;
 }
예제 #8
0
 public ActionResult Edit(Widget widget)
 {
     try
     {
         if (ModelState.IsValid)
         {
             _case.UpdateWidget(widget);
             return RedirectToAction("Index");
         }
         else
         {
             return View(widget);
         }
     }
     catch
     {
         return View(widget);
     }
 }