Exemplo n.º 1
0
        public Log SaveLog(Log log)
        {
            log.LoggedOn = DateTime.UtcNow;

            _logsRepository.SaveOrUpdate(log);

            return(GetWorkLogById(log.LogId));
        }
Exemplo n.º 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);
        }
Exemplo n.º 3
0
        public CustomStateDetail SaveDetail(CustomStateDetail customStateDetail)
        {
            _customStateDetailRepository.SaveOrUpdate(customStateDetail);
            _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent()
            {
                DepartmentId = customStateDetail.CustomState.DepartmentId
            });

            return(customStateDetail);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 6
0
        public DepartmentCallPriority SaveCallPriority(DepartmentCallPriority callPriority)
        {
            _departmentCallPriorityRepository.SaveOrUpdate(callPriority);
            InvalidateCallPrioritiesForDepartmentInCache(callPriority.DepartmentId);

            return(callPriority);
        }
Exemplo n.º 7
0
        public DepartmentCallPruning SavelDepartmentCallPruning(DepartmentCallPruning callPruning)
        {
            _departmentCallPruningRepository.SaveOrUpdate(callPruning);


            return(callPruning);
        }
Exemplo n.º 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);
        }
Exemplo n.º 9
0
        public DepartmentCallPruning SavelDepartmentCallPruning(DepartmentCallPruning callPruning)
        {
            _departmentCallPruningRepository.SaveOrUpdate(callPruning);


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

            return(auditLog);
        }
Exemplo n.º 11
0
        public CallLog SaveCallLog(CallLog log)
        {
            log.LoggedOn = DateTime.UtcNow;

            _callLogsRepository.SaveOrUpdate(log);

            return(GetCallLogById(log.CallLogId));
        }
Exemplo n.º 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);
            //}
        }
Exemplo n.º 13
0
        public Unit SaveUnit(Unit unit)
        {
            _unitsRepository.SaveOrUpdate(unit);
            _eventAggregator.SendMessage <DepartmentSettingsUpdateEvent>(new DepartmentSettingsUpdateEvent()
            {
                DepartmentId = unit.DepartmentId
            });

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

            return(note);
        }
Exemplo n.º 15
0
        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);
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
            }
        }
Exemplo n.º 28
0
        public DepartmentLink Save(DepartmentLink link)
        {
            _departmentLinksRepository.SaveOrUpdate(link);

            return(link);
        }
Exemplo n.º 29
0
        public CallAttachment SaveCallAttachment(CallAttachment attachment)
        {
            _callAttachmentRepository.SaveOrUpdate(attachment);

            return(attachment);
        }
Exemplo n.º 30
0
        public CallNote SaveCallNote(CallNote note)
        {
            _callNotesRepository.SaveOrUpdate(note);

            return(note);
        }