Exemple #1
0
        /// <summary>
        /// Add a notification user
        /// </summary>
        /// <param name="notificationUser"></param>
        /// <returns></returns>
        public int Add(NotificationUserDomain notificationUser)
        {
            var notificationDb = new NotificationUser().FromDomainModel(notificationUser);

            _context.NotificationUser.Add(notificationDb);
            _context.SaveChanges();
            return(notificationDb.NotificationUserId);
        }
Exemple #2
0
        /// <summary>
        /// Update notification user
        /// </summary>
        /// <param name="notificationUser"></param>
        public void UpdateNotificationUser(NotificationUserDomain notificationUser)
        {
            ValidateNotificationModel(notificationUser);
            ValidationHelper.GreaterThanZero(notificationUser.Id, NotificationMessages.NotificationUserIdInvalid);
            ValidationHelper.NotNull(_notificationUserRepository.GetById(notificationUser.Id), NotificationMessages.NotificationUserWithIdDoesNotExist);

            _notificationUserRepository.Update(notificationUser);
        }
Exemple #3
0
        /// <summary>
        /// Update notification user
        /// </summary>
        /// <param name="notificationUser"></param>
        public void Update(NotificationUserDomain notificationUser)
        {
            var notificationDb = _context.NotificationUser.First(x => x.NotificationUserId == notificationUser.Id);

            if (notificationDb != null)
            {
                notificationDb.FromDomainModel(notificationUser);
                _context.SaveChanges();
            }
        }
Exemple #4
0
 private void ValidateNotificationModel(NotificationUserDomain notificationUser)
 {
     ValidationHelper.NotNull(notificationUser, NotificationMessages.NotificationUserNotProvided);
     ValidationHelper.NotNull(notificationUser.NotificationId, NotificationMessages.NotificationIdNotProvided);
     ValidationHelper.NotNull(notificationUser.UserInfoId, NotificationMessages.UserIdNotProvided);
     ValidationHelper.NotNull(notificationUser.UserTenantId, NotificationMessages.NotificationTypeIdNotProvided);
     ValidationHelper.GreaterThanZero(notificationUser.NotificationId, NotificationMessages.NotificationIdInvalid);
     ValidationHelper.GreaterThanZero(notificationUser.UserInfoId, NotificationMessages.UserIdInvalid);
     ValidationHelper.NotNull(_notificationRepository.GetById(notificationUser.NotificationId), NotificationMessages.NotificationWithIdDoesNotExist);
     ValidationHelper.NotNull(_userRepository.GetUserById(notificationUser.UserInfoId), NotificationMessages.UserWithIdDoesNotExist);
     ValidationHelper.NotNull(_userRepository.GetUsersByTenantId(notificationUser.UserTenantId), NotificationMessages.UserWithTenantIdDoesNotExist);
 }
        public static NotificationUser FromDomainModel(this NotificationUser obj, NotificationUserDomain domain)
        {
            if (obj == null)
            {
                obj = new NotificationUser();
            }

            obj.NotificationUserId = domain.Id;
            obj.NotificationId     = domain.NotificationId;
            obj.UserInfoId         = domain.UserInfoId;
            obj.UserTenantId       = domain.UserTenantId;

            return(obj);
        }
        public IHttpActionResult Add(AddNotificationUserRequest request)
        {
            request.ValidateNotNull();

            // convert from request model to domain model
            var notificationUserDomain = new NotificationUserDomain()
            {
                NotificationId = request.NotificationId,
                UserInfoId     = request.UserId,
                UserTenantId   = request.TenantId
            };

            return(Ok(new AddNotificationUserResponse()
            {
                Data = _notificationUserManipulation.AddNotificationUser(notificationUserDomain),
                Success = Common.Enumerations.ResponseStatus.Succeeded
            }));
        }
Exemple #7
0
 /// <summary>
 /// Add notification user
 /// </summary>
 /// <param name="notificationUser"></param>
 /// <returns></returns>
 public int AddNotificationUser(NotificationUserDomain notificationUser)
 {
     ValidateNotificationModel(notificationUser);
     return(_notificationUserRepository.Add(notificationUser));
 }