public IActionResult Create(TimeLineAddForm form) { if (_sessionManager.User is not null) { try { if (ModelState.IsValid) { TimeLine tl = new TimeLine() { DinerDate = form.DinerDate , NbrGuests = form.NbrGuests , UserId = _sessionManager.User.Id , RestaurantId = form.SelectedResaurant }; TimeLine tl2 = _timeLineService.Add(tl); return(RedirectToAction("index")); } } catch (Exception ex) { ModelState.AddModelError("", ex.Message); //ViewBag.Error = ex.Message; } return(View()); } else { return(RedirectToAction("Login", "Auth")); } }
public TimeLine Add(TimeLine tl) { if (tl is null) { throw new NullReferenceException($"TimeLine Data empty ({where}) (ADD)"); } return(_globalService.Add(tl.ToGlobal()).ToClient()); }
public IActionResult Add([FromRoute] int userId, [FromBody] TimeLineAddForm tl) { try { if (tl is null) { throw new ArgumentNullException("TimeLine Object Empty (ADD)"); } TimeLine tlo = new TimeLine() { UserId = tl.UserId, RestaurantId = tl.RestaurantId, DinerDate = tl.DinerDate, NbrGuests = tl.NbrGuests }; tlo = _clientService.Add(tlo); return(ApiControllerHelper.SendOk(this, new ApiResult <TimeLine>(HttpStatusCode.OK, null, tlo), true)); } catch (Exception ex) { return(ApiControllerHelper.SendError(this, ex)); } }
public TimeLine Add(TimeLine tl) { return(_globalService.Add(tl.ToGlobal()).ToClient()); }