public async Task <IHttpActionResult> CrudNotificationType(CrudNotificationTypeInput input)
        {
            switch (input.Action)
            {
            case "insert":
                var result = await _notificationTypeService.AddAsync(input.Value).ConfigureAwait(false);

                return(Ok(result));

            case "update":
                await _notificationTypeService.UpdateAsync(input.Value).ConfigureAwait(false);

                return(Ok(input.Value));

            case "remove":
                await _notificationTypeService.DeleteAsync(Guid.Parse(input.Key)).ConfigureAwait(false);

                return(Ok(new
                {
                    input.Key
                }));

            default:
                return(BadRequest());
            }
        }
Exemple #2
0
        public async Task <IActionResult> PutAsync(int notificationtypeId, [FromBody] SaveNotificationTypeResource resource)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState.GetErrorMessages()));
            }

            var notificationType = _mapper.Map <SaveNotificationTypeResource, NotificationType>(resource);
            var result           = await _notificationTypeService.UpdateAsync(notificationtypeId, notificationType);

            if (!result.Success)
            {
                return(BadRequest(result.Message));
            }
            var notificationTypeResource = _mapper.Map <NotificationType, NotificationTypeResource>(result.Resource);

            return(Ok(notificationTypeResource));
        }