Beispiel #1
0
        public Log SaveLog(Log log)
        {
            log.LoggedOn = DateTime.UtcNow;

            _logsRepository.SaveOrUpdate(log);

            return(GetWorkLogById(log.LogId));
        }
Beispiel #2
0
        public PushLog LogPushResult(string deviceConnectionStatus, string httpStatusCode, string messageId, string notificationStatus, string subscriptionStatus, string channelUri)
        {
            PushLog log = new PushLog();

            _pushLogsRepository.SaveOrUpdate(log);

            return(log);
        }
Beispiel #3
0
        public CustomStateDetail SaveDetail(CustomStateDetail customStateDetail)
        {
            _customStateDetailRepository.SaveOrUpdate(customStateDetail);
            _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent()
            {
                DepartmentId = customStateDetail.CustomState.DepartmentId
            });

            return(customStateDetail);
        }
Beispiel #4
0
        public void RejectTradeRequest(int shiftTradeId, string userId, string reason)
        {
            var trade = GetShiftTradeById(shiftTradeId);

            var userTradeRequest = trade.Users.FirstOrDefault(x => x.UserId == userId);

            if (userTradeRequest != null)
            {
                userTradeRequest.Declined = true;
                userTradeRequest.Reason   = reason;

                _shiftSignupTradeUserRepository.SaveOrUpdate(userTradeRequest);
            }
        }
Beispiel #5
0
        public void AddUnitStateRoleForEvent(int unitStateId, string userId, int roleId, string unitName, DateTime timestamp, string roleName = "Unknown")
        {
            if (unitStateId <= 0)
            {
                throw new ArgumentException("Unit State Id cannot be 0", "unitStateId");
            }

            if (String.IsNullOrWhiteSpace(userId))
            {
                throw new ArgumentException("User Id cannot be an empty Guid", "userId");
            }

            if (roleId <= 0)
            {
                throw new ArgumentException("Role Id cannot be 0", "roleId");
            }

            //var role = GetRoleById(roleId);
            //string roleName = "Unknown";

            //if (role != null)
            //	roleName = role.Name;

            var unitStateRole = new UnitStateRole();

            unitStateRole.UnitStateId = unitStateId;
            unitStateRole.UserId      = userId;
            unitStateRole.Role        = roleName;

            //_userStateService.CreateUserState(userId, (int)UserStateTypes.Committed, string.Format("On {0}", unitName), timestamp);

            _unitStateRoleRepository.SaveOrUpdate(unitStateRole);
        }
Beispiel #6
0
        public DepartmentCallPriority SaveCallPriority(DepartmentCallPriority callPriority)
        {
            _departmentCallPriorityRepository.SaveOrUpdate(callPriority);
            InvalidateCallPrioritiesForDepartmentInCache(callPriority.DepartmentId);

            return(callPriority);
        }
Beispiel #7
0
        public DepartmentCallPruning SavelDepartmentCallPruning(DepartmentCallPruning callPruning)
        {
            _departmentCallPruningRepository.SaveOrUpdate(callPruning);


            return(callPruning);
        }
Beispiel #8
0
        public UnitType AddUnitType(int departmentId, string name, int customStatesId)
        {
            var type = new UnitType();

            type.DepartmentId = departmentId;
            type.Type         = name;

            if (customStatesId != 0)
            {
                type.CustomStatesId = customStatesId;
            }

            _unitTypesRepository.SaveOrUpdate(type);

            return(type);
        }
Beispiel #9
0
        public DepartmentCallPruning SavelDepartmentCallPruning(DepartmentCallPruning callPruning)
        {
            _departmentCallPruningRepository.SaveOrUpdate(callPruning);


            return(GetDepartmentCallPruningSettings(callPruning.DepartmentId));
        }
Beispiel #10
0
        public AuditLog SaveAuditLog(AuditLog auditLog)
        {
            auditLog.LoggedOn = DateTime.UtcNow;
            _auditLogsRepository.SaveOrUpdate(auditLog);

            return(auditLog);
        }
Beispiel #11
0
        public CallLog SaveCallLog(CallLog log)
        {
            log.LoggedOn = DateTime.UtcNow;

            _callLogsRepository.SaveOrUpdate(log);

            return(GetCallLogById(log.CallLogId));
        }
Beispiel #12
0
        public void CreateInvites(Department department, string addingUserId, List <string> emailAddresses)
        {
            var sendingUser    = _usersService.GetUserById(addingUserId);
            var sendingProfile = _userProfileService.GetProfileByUserId(addingUserId);

            for (int i = 0; i < emailAddresses.Count; i++)
            {
                Invite invite = new Invite();
                invite.Code          = Guid.NewGuid();
                invite.DepartmentId  = department.DepartmentId;
                invite.EmailAddress  = emailAddresses[i];
                invite.SendingUserId = addingUserId;
                invite.SentOn        = DateTime.Now.ToUniversalTime();

                _invitesRepository.SaveOrUpdate(invite);

                if (invite.Department == null)
                {
                    invite.Department = _departmentsService.GetDepartmentById(department.DepartmentId);
                }



                _emailService.SendInvite(invite, sendingProfile.FullName.AsFirstNameLastName, sendingUser.Email);
            }

            //foreach (var email in emailAddresses)
            //{
            //	Invite invite = new Invite();
            //	invite.Code = Guid.NewGuid();
            //	invite.DepartmentId = department.DepartmentId;
            //	invite.EmailAddress = email;
            //	invite.SendingUserId = addingUserId;
            //	invite.SentOn = DateTime.Now.ToUniversalTime();

            //	_invitesRepository.SaveOrUpdate(invite);

            //	if (invite.Department == null)
            //		invite.Department = _departmentsService.GetDepartmentById(department.DepartmentId);

            //	_emailService.SendInvite(invite);
            //}
        }
Beispiel #13
0
        public Unit SaveUnit(Unit unit)
        {
            _unitsRepository.SaveOrUpdate(unit);
            _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent()
            {
                DepartmentId = unit.DepartmentId
            });

            return(unit);
        }
Beispiel #14
0
        public Note Save(Note note)
        {
            _notesRepository.SaveOrUpdate(note);
            _eventAggregator.SendMessage <NoteAddedEvent>(new NoteAddedEvent()
            {
                DepartmentId = note.DepartmentId, Note = note
            });

            return(note);
        }
        public DistributionList SaveDistributionList(DistributionList distributionList)
        {
            if (distributionList.DistributionListId == 0)
            {
                _distributionListRepository.SaveOrUpdate(distributionList);
            }
            else
            {
                var members = (from m in _distributionListMemberRepository.GetAll()
                               where m.DistributionListId == distributionList.DistributionListId
                               select m).AsEnumerable();

                _distributionListMemberRepository.DeleteAll(members);

                _distributionListRepository.SaveOrUpdate(distributionList);
            }

            return(distributionList);
        }
Beispiel #16
0
        public void UpdateShiftGroups(Shift shift, List <ShiftGroup> groups)
        {
            _shiftGroupsRepository.DeleteAll(shift.Groups.ToList());

            foreach (var group in groups)
            {
                group.ShiftId = shift.ShiftId;
                _shiftGroupsRepository.SaveOrUpdate(group);
            }
        }
Beispiel #17
0
        public void SetTrainingAsViewed(int trainingId, string userId)
        {
            var trainingUser =
                _trainingUserRepository.GetAll().FirstOrDefault(x => x.TrainingId == trainingId && x.UserId == userId);

            if (trainingUser != null)
            {
                trainingUser.Viewed   = true;
                trainingUser.ViewedOn = DateTime.UtcNow;

                if (trainingUser.Training.Questions == null || trainingUser.Training.Questions.Count <= 0)
                {
                    trainingUser.Complete    = true;
                    trainingUser.CompletedOn = DateTime.UtcNow;
                }

                _trainingUserRepository.SaveOrUpdate(trainingUser);
            }
        }
Beispiel #18
0
        public DepartmentCertificationType SaveNewCertificationType(string certificationType, int departmentId)
        {
            DepartmentCertificationType newCertType = new DepartmentCertificationType();

            newCertType.DepartmentId = departmentId;
            newCertType.Type         = certificationType;

            _departmentCertificationTypeRepository.SaveOrUpdate(newCertType);

            return(GetCertificationTypeById(newCertType.DepartmentCertificationTypeId));
        }
Beispiel #19
0
        public void UpdateShiftPersonnel(Shift shift, List <ShiftPerson> newPersonnel)
        {
            var dbShift = GetShiftById(shift.ShiftId);

            _shiftPersonRepository.DeleteAll(dbShift.Personnel.ToList());

            foreach (var person in newPersonnel)
            {
                person.ShiftId = shift.ShiftId;
                _shiftPersonRepository.SaveOrUpdate(person);
            }
        }
Beispiel #20
0
        public CustomState Save(CustomState customState)
        {
            _customStateRepository.SaveOrUpdate(customState);

            _cacheProvider.Remove(string.Format(CacheKey, customState.DepartmentId));

            _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent()
            {
                DepartmentId = customState.DepartmentId
            });

            return(customState);
        }
Beispiel #21
0
        public ShiftSignup SignupForShiftDay(int shiftId, DateTime shiftDay, int departmentGroupId, string userId)
        {
            var signup = new ShiftSignup();

            signup.ShiftId           = shiftId;
            signup.ShiftDay          = shiftDay;
            signup.SignupTimestamp   = DateTime.UtcNow;
            signup.UserId            = userId;
            signup.DepartmentGroupId = departmentGroupId;
            signup.Denied            = false;

            _shiftSignupRepository.SaveOrUpdate(signup);

            return(signup);
        }
Beispiel #22
0
        public List <QueueItem> Dequeue(QueueTypes type)
        {
            var items = (from q in _queueItemsRepository.GetAll()
                         where q.QueueType == (int)type && q.PickedUp == null && q.CompletedOn == null
                         select q).ToList();

            foreach (var i in items)
            {
                i.PickedUp = DateTime.Now.ToUniversalTime();
                _queueItemsRepository.SaveOrUpdate(i);
            }

            return(items);
        }
Beispiel #23
0
        public Permission SetPermissionForDepartment(int departmentId, string userId, PermissionTypes type, PermissionActions action, string data, bool lockToGroup)
        {
            var permission = GetPermisionByDepartmentType(departmentId, type) ?? new Permission();

            permission.DepartmentId   = departmentId;
            permission.PermissionType = (int)type;
            permission.Action         = (int)action;
            permission.Data           = data;
            permission.LockToGroup    = lockToGroup;
            permission.UpdatedBy      = userId;
            permission.UpdatedOn      = DateTime.UtcNow;

            _permissionsRepository.SaveOrUpdate(permission);

            return(permission);
        }
Beispiel #24
0
        public void SignupForEvent(int calendarEventItemId, string userId, string note, int attendeeType)
        {
            CalendarItemAttendee attendee = GetCalendarItemAttendeeByUser(calendarEventItemId, userId);

            if (attendee == null)
            {
                attendee = new CalendarItemAttendee();
            }

            attendee.CalendarItemId = calendarEventItemId;
            attendee.UserId         = userId;
            attendee.Note           = note;
            attendee.AttendeeType   = attendeeType;
            attendee.Timestamp      = DateTime.UtcNow;

            _calendarItemAttendeeRepository.SaveOrUpdate(attendee);
        }
Beispiel #25
0
        public void SetRolesForUser(int departmentId, string userId, string[] roleIds)
        {
            RemoveUserFromAllRoles(userId, departmentId);
            var roles = GetAllRolesForDepartment(departmentId);

            foreach (var roleId in roleIds)
            {
                var role = roles.FirstOrDefault(x => x.PersonnelRoleId == int.Parse(roleId));

                if (role != null)
                {
                    var roleUser = new PersonnelRoleUser();
                    roleUser.UserId          = userId;
                    roleUser.DepartmentId    = departmentId;
                    roleUser.PersonnelRoleId = role.PersonnelRoleId;

                    _personnelRoleUsersRepository.SaveOrUpdate(roleUser);
                }
            }
        }
Beispiel #26
0
        public Job SetJobAsStarted(JobTypes jobType, int checkInterval)
        {
            Job job = _jobsRepository.GetAll().FirstOrDefault(x => x.JobType == (int)jobType);

            if (job != null)
            {
                job.DoRestart      = false;
                job.StartTimestamp = DateTime.UtcNow;
                _jobsRepository.SaveOrUpdate(job);
            }
            else
            {
                job                = new Job();
                job.JobType        = (int)jobType;
                job.CheckInterval  = checkInterval;
                job.StartTimestamp = DateTime.UtcNow;

                _jobsRepository.SaveOrUpdate(job);
            }

            return(job);
        }
Beispiel #27
0
        public void UpdateShiftDates(Shift shift, List <ShiftDay> days)
        {
            // Adding Days
            foreach (var day in days)
            {
                // Don't re-add days already that are apart of the shift
                if (!shift.Days.Any(x => x.Day.Day == day.Day.Day && x.Day.Month == day.Day.Month && x.Day.Year == day.Day.Year))
                {
                    day.ShiftId = shift.ShiftId;
                    _shiftDaysRepository.SaveOrUpdate(day);
                }
            }

            // Removing Days
            var daysToRemove = from sd in shift.Days
                               let day = days.FirstOrDefault(x => x.Day.Day == sd.Day.Day && x.Day.Month == sd.Day.Month && x.Day.Year == sd.Day.Year)
                                         where day == null
                                         select sd;

            if (daysToRemove != null && daysToRemove.Any())
            {
                _shiftDaysRepository.DeleteAll(daysToRemove.ToList());
            }
        }
        public DepartmentLink Save(DepartmentLink link)
        {
            _departmentLinksRepository.SaveOrUpdate(link);

            return(link);
        }
Beispiel #29
0
        public CallAttachment SaveCallAttachment(CallAttachment attachment)
        {
            _callAttachmentRepository.SaveOrUpdate(attachment);

            return(attachment);
        }
Beispiel #30
0
        public CallNote SaveCallNote(CallNote note)
        {
            _callNotesRepository.SaveOrUpdate(note);

            return(note);
        }