コード例 #1
0
        public async Task <IActionResult> CreateNotify([FromBody] NotificationCreateDTO notification)
        {
            var notify = _mapper.Map <Notification>(notification);

            notify.IsPublish = false;
            _repo.Create(notify);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            return(BadRequest("Error on creating"));
        }
コード例 #2
0
        public async Task <IActionResult> UpdateNotify(int id, [FromBody] NotificationCreateDTO notification)
        {
            var notificationFromDb = await _repo.GetOneWithConditionTracking <Notification>(notify => notify.Id == id);

            if (notificationFromDb == null)
            {
                return(NotFound());
            }
            _mapper.Map(notification, notificationFromDb);
            if (await _repo.SaveAll())
            {
                return(Ok());
            }
            else
            {
                return(NoContent());
            }
        }