Esempio n. 1
0
        public IActionResult Add([FromBody] EventViewModel eventObj, Guid idOwner, Guid idLocal)
        {
            try
            {
                var eventDomain = _mapper.Map <EventViewModel, Event>(eventObj);
                var response    = _mapper.Map <Event, EventViewModel>(_eventAppService.Add(eventDomain, idOwner, idLocal));

                return(Ok(response));
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
        }
Esempio n. 2
0
        public async Task <ActionResult> Create(
            [Bind(Include = "EventId,Name,NumberOfDaysToWarning")]
            EventViewModel eventViewModel)
        {
            if (ModelState.IsValid)
            {
                var result = eventAppService.Add(eventViewModel);
                if (!result.IsValid)
                {
                    foreach (var validationAppError in result.Errors)
                    {
                        ModelState.AddModelError(string.Empty, validationAppError.Message);
                    }
                    return(View(eventViewModel));
                }

                // TODO: check if this should be the action to redirect to
                return(RedirectToAction(nameof(Index)));
            }

            return(View(eventViewModel));
        }
Esempio n. 3
0
 public void Post([FromBody] EventViewModel eventSchedule)
 {
     _eventApp.Add(_mapper.Map <EventViewModel, Core.Event.Event>(eventSchedule));
 }