Example #1
0
        public IHttpActionResult Post([FromBody] UpdateConcertProgrammModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            var userId  = User.Identity.GetUserId <int>();
            var succes  = ServiceResponce.FromSuccess().Result("Concert save complete");
            var error   = ServiceResponce.FromFailed().Result($"Error save concert");
            var concert = _concertService.SaveConcert(model.Concert, userId);

            if (model.Programms != null)
            {
                foreach (var el in model.Programms)
                {
                    _concertService.UpdateConcertProgramm(el);
                }
            }
            if (model.Actors != null)
            {
                foreach (var el in model.Actors)
                {
                    _concertService.UpdateActor(el);
                }
            }
            if (concert == null)
            {
                return(Ok(error.Response()));
            }
            succes.Add("concertId", concert.Id);
            return(Ok(succes.Response()));
        }