public async Task <ApiResponse> Post(AddNotificationVMRequest entity)
        {
            try
            {
                List <long> usersToSendNotifications = new();
                foreach (var item in entity.UserCIds)
                {
                    Notification notification = new()
                    {
                        Title   = entity.Title,
                        Body    = entity.Body,
                        Type    = entity.Type,
                        UserCId = item,
                        Link    = entity.Link
                    };

                    var newEntity = await _entityRepository.InsertAsync(notification);

                    usersToSendNotifications.Add(newEntity.Id);
                }
                return(ApiResponse.Create(HttpStatusCode.OK, usersToSendNotifications));
            }
            catch (Exception)
            {
                return(ApiResponse.Create(HttpStatusCode.InternalServerError, null, "InternalServerError_Error"));
            }
        }
Ejemplo n.º 2
0
        public async Task <List <long> > Create(AddNotificationVMRequest entity)
        {
            var response = await _httpService.Post2 <AddNotificationVMRequest, List <long> >(url, entity);

            if (!response.Success)
            {
                throw new ApplicationException(await response.GetBody());
            }
            return(response.Response);
        }
        public async Task <ActionResult> Post(AddNotificationVMRequest entity)
        {
            #region Start the watch
            var watch = new Stopwatch();
            watch.Start();
            #endregion

            var result = await _entityServices.Post(entity);

            #region End the watch
            watch.Stop();
            result.Meta.TotalProcessingTime = watch.ElapsedMilliseconds;
            #endregion

            return(Ok(result));
        }