/// <summary>
 /// Update web notification
 /// </summary>
 /// <param name="webNotification"></param>
 public void UpdateWebNotification(WebNotificationDomain webNotification)
 {
     ValidateWebNotificationModel(webNotification);
     ValidationHelper.GreaterThanZero(webNotification.Id, NotificationMessages.WebNotificationIdInvalid);
     ValidationHelper.NotNull(_webNotificationRepository.GetById(webNotification.Id), NotificationMessages.WebNotificationWithIdDoesNotExist);
     _webNotificationRepository.Update(webNotification);
 }
Beispiel #2
0
        /// <summary>
        /// Update a web notification
        /// </summary>
        /// <param name="domain"></param>
        public void Update(WebNotificationDomain domain)
        {
            WebNotification webNotification = _context.WebNotification.FirstOrDefault(x => x.WebNotificationId == domain.Id);

            webNotification.FromDomainModel(domain);
            _context.SaveChanges();
        }
Beispiel #3
0
        public IHttpActionResult UpdateUnseenWebNotification(UpdateWebNotificationRequest request)
        {
            try
            {
                request.ValidateNotNull();

                WebNotificationDomain domain = _webNotificationManipulation.GetWebNotificationById(request.Id);
                if (domain == null)
                {
                    return(NotFound());
                }

                if (!domain.Seen)
                {
                    domain.Seen     = true;
                    domain.DateSeen = DateTime.UtcNow;
                    _webNotificationManipulation.UpdateWebNotification(domain);
                }

                return(Ok(new UpdateWebNotificationResponse()
                {
                    Success = Common.Enumerations.ResponseStatus.Succeeded
                }));
            }
            catch (NsiBaseException e)
            {
                return(BadRequest(e.Message));
            }
        }
 private void ValidateWebNotificationModel(WebNotificationDomain webNotification)
 {
     ValidationHelper.NotNull(webNotification, NotificationMessages.WebNotificationNotProvided);
     ValidationHelper.GreaterThanZero(webNotification.NotificationId, NotificationMessages.WebNotificationNotificationIdInvalid);
     ValidationHelper.NotNull(_notificationRepository.GetById(webNotification.NotificationId), NotificationMessages.NotificationWithIdDoesNotExist);
     ValidationHelper.GreaterThanZero(webNotification.UserInfoId, NotificationMessages.WebNotificationUserInfoIdInvalid);
     ValidationHelper.NotNull(_userRepository.GetUserById(webNotification.UserInfoId), NotificationMessages.WebNotificationUserDoesNotExist);
 }
Beispiel #5
0
        /// <summary>
        /// Add a web notification
        /// </summary>
        /// <param name="domain"></param>
        /// <returns></returns>
        public int Add(WebNotificationDomain domain)
        {
            WebNotification webNotification = new WebNotification().FromDomainModel(domain);

            _context.WebNotification.Add(webNotification);
            _context.SaveChanges();
            return(webNotification.WebNotificationId);
        }
Beispiel #6
0
        public static WebNotification FromDomainModel(this WebNotification obj, WebNotificationDomain domain)
        {
            if (obj == null)
            {
                obj = new WebNotification();
            }

            obj.WebNotificationId = domain.Id;
            obj.Seen           = domain.Seen;
            obj.DateSeen       = domain.DateSeen;
            obj.NotificationId = domain.NotificationId;
            obj.UserInfoId     = domain.UserInfoId;
            obj.UserTenantId   = domain.UserTenantId;

            return(obj);
        }
Beispiel #7
0
        public IHttpActionResult AddWebNotification(AddWebNotificationRequest request)
        {
            try
            {
                request.ValidateNotNull();

                WebNotificationDomain domain = new WebNotificationDomain();
                domain.NotificationId = request.NotificationId;
                domain.UserInfoId     = request.UserInfoId;
                domain.UserTenantId   = request.UserTenantId;

                int id = _webNotificationManipulation.AddWebNotification(domain);

                return(Ok(new AddWebNotificationResponse()
                {
                    Data = id,
                    Success = Common.Enumerations.ResponseStatus.Succeeded
                }));
            }
            catch (NsiBaseException e)
            {
                return(BadRequest(e.Message));
            }
        }
 /// <summary>
 /// Add a web notification
 /// </summary>
 /// <param name="webNotification"></param>
 /// <returns></returns>
 public int AddWebNotification(WebNotificationDomain webNotification)
 {
     ValidateWebNotificationModel(webNotification);
     return(_webNotificationRepository.Add(webNotification));
 }