示例#1
0
        public BaseResponse AddNotification(NotificationDto notificationDto)
        {
            var response = new BaseResponse();

            try {
                var notificationRepository = new NotificationRepository();
                var newNotification        = new Notification()
                {
                    CreateBy    = notificationDto.CreateBy,
                    CreatedDate = DateTime.Now,
                    Text        = notificationDto.Text,
                    UpdatedDate = DateTime.Now,
                    WasViewed   = false
                };
                notificationRepository.Add(newNotification);
                notificationRepository.SaveChanges();
                notificationRepository.Dispose();
                response.Acknowledgment = true;
                response.Message        = "Success";
            }catch (Exception ex) {
                response.Acknowledgment = true;
                response.Message        = "Error addin a notification: " + ex.Message;
            }
            return(response);
        }
示例#2
0
        public bool AddNotification(NOTIFICATION notification)
        {
            bool returnValue = false;

            notification.CREATED_DATE = DateTime.Now;
            returnValue = NotifRepo.Add(notification);
            return(returnValue);
        }
示例#3
0
        internal Notification AddNewDrugNotification(int drugId, int userId)
        {
            Notification notification = new Notification();

            notification.Date = DateTime.Now;
            notification.User = userId;
            notification.Text = NEW_DRUG_NOTIFICATION_TEXT + " " + drugId.ToString();
            return(_notificationRepository.Add(notification));
        }
示例#4
0
        public int RequestUserFriendship(JObject jObj)
        {
            string fromUserId = jObj["fromUserId"].ToString();
            string toUserId   = jObj["toUserId"].ToString();

            Notification notification = new Notification()
            {
                Message                   = $"{GetUserById(fromUserId).Name} gostaria de ser seu amigo.",
                NotificationTime          = DateTime.Now,
                WasRead                   = false,
                NotificationIssuerId      = fromUserId,
                NotifiedApplicationUserId = toUserId
            };

            Nr.Add(notification);

            return(Ar.RequestUserFriendship(fromUserId, toUserId));
        }
        private void RegisterNotification(NotifyClientRequest request, out Notification notification)
        {
            notification = new Notification(request.Title,
                                            request.Message,
                                            request.Owner,
                                            request.ApplicationId,
                                            request.UserContextId);

            notification = _notificationRepository.Add(notification);
        }
        private void RegisterNotification(NotifyClientAbstraction request,
                                          string owner,
                                          int applicationId,
                                          string userContextId,
                                          out Notification notification)
        {
            notification = new Notification(request.Title,
                                            request.Message,
                                            owner,
                                            applicationId,
                                            userContextId);

            notification = _notificationRepository.Add(notification);
        }
示例#7
0
        public void Agregar(NotificationViewModel pNotificationViewModel)
        {
            notifications onotifications = new notifications
            {
                notification_id = 0,
                user_id         = pNotificationViewModel.user_id,
                date_created    = DateTime.Now,
                user_id_created = pNotificationViewModel.user_id_created,
                url             = pNotificationViewModel.url,
                message         = pNotificationViewModel.message,
                notified        = false,
            };

            oRepositorio.Add(onotifications);
            oUnitOfWork.SaveChanges();
        }
    public override Task CheckItemExpirationDate()
    {
        IItemRepository         itemRepository         = new ItemRepository();
        INotificationRepository notificationRepository = new NotificationRepository();
        List <ItemModel>        listItem = itemRepository.GetAll();

        foreach (ItemModel item in listItem)
        {
            // If item expired, I create the notification and remove it from inventary.
            if (item.ExpirationDate < System.DateTime.Now)
            {
                notificationRepository.Add(item, NotificationTypes.Expirate);
                itemRepository.Remove(item.Id);
            }
        }

        return(Task.CompletedTask);
    }
        public async Task <bool> AddNotification(DTONotification notification)
        {
            Notification mapNotification = _mapper.Map <Notification>(notification);

            _notificationRepository.Add(mapNotification);
            bool success = true;

            try
            {
                await _notificationRepository.SaveChanges();
            }
            catch
            {
                success = false;
            }

            return(success);
        }