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 IActionResult Create()
 {
     if (_sessionManager.User is not null)
     {
         TimeLineAddForm start = new TimeLineAddForm()
         {
             NbrGuests           = 1
             , DinerDate         = DateTime.Today
             , SelectedResaurant = 0
             , Restaurants       = GetRestaurants()
         };
         return(View(start));
     }
     else
     {
         return(RedirectToAction("Login", "Auth"));
     }
 }
        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));
            }
        }