Пример #1
0
        public async Task <IActionResult> CreateCalendar(CreateCalendarRequest request)
        {
            var calendar = _calendarRepository.Create(new Calendar()
            {
                Name = request.Name
            });

            _userCalendar.LinkCalendarToUser(calendar.Id, this.GetUserId());
            return(Ok());
        }
Пример #2
0
        public ActionResult Create([FromForm] CreateCalendarInputModel inputModel)
        {
            if (!this.TryValidateModel(inputModel))
            {
                return(Ok(new ApiResultModel <int>(200, 10)));
            }
            var row    = _calendarRepository.Create(inputModel);
            int status = 0;

            if (row == null)
            {
                status = 1;
            }
            return(Ok(new ApiResultModel <int>(200, status)));
        }
Пример #3
0
        public async Task <ActionResult <Calendar> > CreateCalender([FromBody] Calendar calendar)
        {
            try
            {
                await _repository.Create(calendar);

                return(CreatedAtRoute("Calendar", new { id = calendar.CalenderId }, calendar));
            }
            catch (Exception exc)
            {
                _logger.LogError($"Error: {exc}");
                // transaction.Rollback();
                return(NotFound());
            }
        }