Example #1
0
        public List <NotesResult> GetAllNotes()
        {
            var results    = new List <NotesResult>();
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            var notes = _notesService.GetNotesForDepartmentFiltered(DepartmentId, department.IsUserAnAdmin(UserId));

            foreach (var n in notes)
            {
                var noteResult = new NotesResult();
                noteResult.Nid = n.NoteId;
                noteResult.Uid = n.UserId;
                noteResult.Ttl = n.Title;
                noteResult.Bdy = StringHelpers.StripHtmlTagsCharArray(n.Body).Truncate(100);
                noteResult.Adn = n.AddedOn.TimeConverter(department);
                noteResult.Cat = n.Category;
                noteResult.Clr = n.Color;

                if (n.ExpiresOn.HasValue)
                {
                    noteResult.Exp = n.ExpiresOn.Value;
                }

                results.Add(noteResult);
            }

            return(results);
        }
Example #2
0
        public Rss20FeedFormatter GetActiveCallsAsRSS(string key)
        {
            if (String.IsNullOrWhiteSpace(key))
            {
                return(null);
            }

            var departmentId = _departmentSettingsService.GetDepartmentIdForRssKey(key);

            if (!departmentId.HasValue)
            {
                return(null);
            }

            var department = _departmentsService.GetDepartmentById(departmentId.Value);
            var calls      = _callsService.GetActiveCallsByDepartment(departmentId.Value);

            var feed = new SyndicationFeed(string.Format("{0} Active Calls", department.Name), string.Format("The active calls for the department {0}", department.Name), new Uri(Config.SystemBehaviorConfig.ResgridBaseUrl));

            feed.Authors.Add(new SyndicationPerson("*****@*****.**"));
            feed.Categories.Add(new SyndicationCategory("Resgrid Calls"));
            feed.Description = new TextSyndicationContent(string.Format("The active calls for the department {0}", department.Name));
            feed.Items       = calls.Select(call => new SyndicationItem(call.Name, call.NatureOfCall, new Uri($"{Config.SystemBehaviorConfig.ResgridBaseUrl}/User/Dispatch/ViewCall?callId=" + call.CallId), call.CallId.ToString(), call.LoggedOn)).ToList();

            return(new Rss20FeedFormatter(feed));
        }
        public void DeleteDepartmentStaffingResetJob(int departmentId)
        {
            var department = _departmentsService.GetDepartmentById(departmentId);

            // TODO: Possible bug here, if they change the managing user after setting up a job, it will miss here
            var tasks = (from st in _scheduledTaskRepository.GetAll()
                         where st.DepartmentId == departmentId && st.TaskType == (int)TaskTypes.DepartmentStaffingReset
                         select st).ToList();

            //var tasks = GetScheduledTasksByUserType(department.ManagingUserId, (int)TaskTypes.DepartmentStaffingReset);

            foreach (var task in tasks)
            {
                _scheduledTaskRepository.DeleteOnSubmit(task);
            }

            var tasks2 = (from st in _scheduledTaskRepository.GetAll()
                          where st.UserId == department.ManagingUserId && st.TaskType == (int)TaskTypes.DepartmentStaffingReset
                          select st).ToList();

            //var tasks = GetScheduledTasksByUserType(department.ManagingUserId, (int)TaskTypes.DepartmentStaffingReset);

            foreach (var task in tasks2)
            {
                _scheduledTaskRepository.DeleteOnSubmit(task);
            }


            InvalidateScheduledTasksCache();
        }
Example #4
0
        public IActionResult Index()
        {
            var model = new IndexView();

            model.Department = _departmentsService.GetDepartmentById(DepartmentId);
            model.Profile    = _departmentProfileService.GetOrInitializeDepartmentProfile(DepartmentId);
            model.ImageUrl   = $"{_appOptionsAccessor.Value.ResgridApiUrl}/api/v3/Avatars/Get?id={model.Profile.DepartmentId}&type=1";

            var posts        = _departmentProfileService.GetArticlesForDepartment(model.Profile.DepartmentProfileId);
            var visiblePosts = _departmentProfileService.GetVisibleArticlesForDepartment(model.Profile.DepartmentProfileId);

            if (visiblePosts != null && visiblePosts.Any())
            {
                model.VisiblePosts = visiblePosts.Count;
            }

            if (posts.Any())
            {
                model.Posts = posts.Skip(Math.Max(0, posts.Count() - 3)).ToList();
            }
            else
            {
                model.Posts = new List <DepartmentProfileArticle>();
            }

            return(View(model));
        }
Example #5
0
        public IActionResult ViewEntry(int inventoryId)
        {
            var model = new ViewEntryView();

            model.Department = _departmentsService.GetDepartmentById(DepartmentId);
            model.Inventory  = _inventoryService.GetInventoryById(inventoryId);

            if (model.Inventory == null || model.Inventory.DepartmentId != DepartmentId)
            {
                Unauthorized();
            }

            var profile = _userProfileService.GetProfileByUserId(model.Inventory.AddedByUserId);

            if (profile != null)
            {
                model.Name = profile.FullName.AsFirstNameLastName;
            }
            else
            {
                model.Name = "Unknown";
            }

            return(View(model));
        }
Example #6
0
        public IActionResult Index()
        {
            LogsIndexView model = new LogsIndexView();

            model.CallLogs   = _workLogsService.GetAllCallLogsForUser(UserId);
            model.WorkLogs   = _workLogsService.GetAllLogsForUser(UserId);
            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);

            return(View(model));
        }
Example #7
0
        public List <CalendarItem> GetDepartmentCalendarItems()
        {
            List <CalendarItem>       jsonItems = new List <CalendarItem>();
            List <Model.CalendarItem> items     = null;

            items = _calendarService.GetAllCalendarItemsForDepartment(DepartmentId);
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            foreach (var item in items)
            {
                CalendarItem calendarItem = new CalendarItem();
                calendarItem.CalendarItemId      = item.CalendarItemId;
                calendarItem.Title               = item.Title;
                calendarItem.Start               = item.Start.TimeConverter(department);
                calendarItem.End                 = item.End.TimeConverter(department);
                calendarItem.StartTimezone       = item.StartTimezone;
                calendarItem.EndTimezone         = item.EndTimezone;
                calendarItem.Description         = item.Description;
                calendarItem.RecurrenceId        = item.RecurrenceId;
                calendarItem.RecurrenceRule      = item.RecurrenceRule;
                calendarItem.RecurrenceException = item.RecurrenceException;
                calendarItem.IsAllDay            = item.IsAllDay;
                calendarItem.ItemType            = item.ItemType;
                calendarItem.Location            = item.Location;
                calendarItem.SignupType          = item.SignupType;
                calendarItem.Reminder            = item.Reminder;
                calendarItem.LockEditing         = item.LockEditing;
                calendarItem.Entities            = item.Entities;
                calendarItem.RequiredAttendes    = item.RequiredAttendes;
                calendarItem.OptionalAttendes    = item.OptionalAttendes;

                if (!String.IsNullOrWhiteSpace(item.CreatorUserId))
                {
                    calendarItem.CreatorUserId = item.CreatorUserId.ToString();
                }

                if (department.IsUserAnAdmin(UserId))
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else if (!String.IsNullOrWhiteSpace(item.CreatorUserId) && item.CreatorUserId == UserId)
                {
                    calendarItem.IsAdminOrCreator = true;
                }
                else
                {
                    calendarItem.IsAdminOrCreator = false;
                }


                jsonItems.Add(calendarItem);
            }

            return(jsonItems);
        }
Example #8
0
        public IActionResult Index()
        {
            var model = new LinksIndexView();

            model.DepartmentId   = DepartmentId;
            model.Links          = _departmentLinksService.GetAllLinksForDepartment(DepartmentId);
            model.CanCreateLinks = _limitsService.CanDepartmentUseLinks(DepartmentId);

            var department = _departmentsService.GetDepartmentById(DepartmentId);

            model.Code = department.LinkCode;

            return(View(model));
        }
Example #9
0
        public void SendInvite(Invite invite, string senderName, string senderEmail)
        {
            if (invite == null)
            {
                return;
            }

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

            _emailProvider.SendInviteMail(invite.Code.ToString(), invite.Department.Name, invite.EmailAddress, senderName, senderEmail);
        }
Example #10
0
        public IActionResult Report(int trainingId)
        {
            var model = new TrainingReportView();

            model.Training   = _trainingService.GetTrainingById(trainingId);
            model.UserGroups = new Dictionary <string, string>();
            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);

            if (model.Training.DepartmentId != DepartmentId)
            {
                Unauthorized();
            }

            foreach (var user in model.Training.Users)
            {
                var group = _departmentGroupsService.GetGroupForUser(user.UserId, DepartmentId);

                if (group != null)
                {
                    model.UserGroups.Add(user.UserId, group.Name);
                }
            }

            return(View(model));
        }
Example #11
0
        public DepartmentProfile GetOrInitializeDepartmentProfile(int departmentId)
        {
            DepartmentProfile profile = GetDepartmentProfileByDepartmentId(departmentId);

            if (profile != null)
            {
                return(profile);
            }

            Department department = _departmentsService.GetDepartmentById(departmentId);

            profile              = new DepartmentProfile();
            profile.Code         = $"{RandomGenerator.CreateCode(2)}-{RandomGenerator.CreateCode(4)}";
            profile.DepartmentId = departmentId;
            profile.Name         = department.Name;

            var mapCenterGpsCoordinates = _departmentSettingsService.GetBigBoardCenterGpsCoordinatesDepartment(departmentId);

            if (!String.IsNullOrWhiteSpace(mapCenterGpsCoordinates))
            {
                string[] coordinates = mapCenterGpsCoordinates.Split(char.Parse(","));

                if (coordinates.Count() == 2)
                {
                    profile.Latitude  = coordinates[0];
                    profile.Longitude = coordinates[1];
                }
            }
            else
            {
                profile.AddressId = department.AddressId;
            }

            return(SaveDepartmentProfile(profile));
        }
Example #12
0
        public List <DepartmentResult> Get(int departmentId)
        {
            List <DepartmentResult> result = new List <DepartmentResult>();

            if (departmentId == 0 && IsSystem)
            {
                // Get All
                var departments = _departmentsService.GetAll();

                foreach (var department in departments)
                {
                    result.Add(DepartmentToResult(department));
                }

                return(result);
            }
            else if (departmentId >= 1)
            {
                if (departmentId == DepartmentId)
                {
                    var department = _departmentsService.GetDepartmentById(departmentId);
                    result.Add(DepartmentToResult(department));

                    return(result);
                }
                else
                {
                    throw HttpStatusCode.Unauthorized.AsException();
                }
            }
            else
            {
                throw HttpStatusCode.BadRequest.AsException();
            }
        }
Example #13
0
        public IActionResult GetAuditLogsList()
        {
            var auditLogsJson = new List <AuditLogJson>();
            var auditLogs     = _auditService.GetAllAuditLogsForDepartment(DepartmentId);
            var department    = _departmentsService.GetDepartmentById(DepartmentId, false);

            foreach (var auditLog in auditLogs)
            {
                var auditJson = new AuditLogJson();
                auditJson.AuditLogId = auditLog.AuditLogId;
                //auditJson.Name = UserHelper.GetFullNameForUser(null, auditLog.UserId);
                auditJson.Message = auditLog.Message;

                if (auditLog.LoggedOn.HasValue)
                {
                    auditJson.Timestamp = auditLog.LoggedOn.Value.TimeConverterToString(department);
                }
                else
                {
                    auditJson.Timestamp = "Unknown";
                }

                auditJson.Type = _auditService.GetAuditLogTypeString((AuditLogTypes)auditLog.LogType);

                auditLogsJson.Add(auditJson);
            }

            return(Json(auditLogsJson));
        }
Example #14
0
        public async Task <List <ResourceOrder> > GetOpenAvailableOrders(int departmentId)
        {
            var orders = new List <ResourceOrder>();

            var departmentSettings = await _resourceOrdersRepository.GetOrderSettingByDepartmentId(departmentId);

            var department        = _departmentsService.GetDepartmentById(departmentId);
            var mapCenterLocation = _departmentSettingsService.GetMapCenterCoordinates(department);

            // Target department does not want to recieve orders
            if (departmentSettings != null && departmentSettings.DoNotReceiveOrders)
            {
                return(orders);
            }

            //var allRangeOrders = await _resourceOrdersRepository.GetAllOpenOrdersByRange(departmentId);
            var allRangeOrders =
                await _genericResourceOrderRepository.GetAll()
                .Where(x => x.DepartmentId != departmentId && x.CloseDate == null && x.Visibility == 0)
                .ToListAsync();

            orders.AddRange(allRangeOrders.Where(x => (x.OriginLocation.GetDistanceTo(new GeoCoordinate(mapCenterLocation.Latitude.Value, mapCenterLocation.Longitude.Value)) / 1609.344) <= x.Range));
            //orders.AddRange(await _resourceOrdersRepository.GetAllOpenOrdersUnrestricted(departmentId));
            orders.AddRange(await _genericResourceOrderRepository.GetAll().Where(x => x.DepartmentId != departmentId && x.CloseDate == null && x.Visibility == 3).ToListAsync());
            orders.AddRange(await _resourceOrdersRepository.GetAllOpenOrdersLinked(departmentId));

            return(orders);
        }
Example #15
0
        /// <summary>
        /// Gets the current users department rights
        /// </summary>
        /// <returns>DepartmentRightsResult object with the department rights and group memberships</returns>
        public DepartmentRightsResult GetCurrentUsersRights()
        {
            var result               = new DepartmentRightsResult();
            var department           = _departmentsService.GetDepartmentById(DepartmentId, false);
            var departmentMembership = _departmentsService.GetDepartmentMember(UserId, DepartmentId, false);
            var roles = _personnelRolesService.GetRolesForUser(UserId, DepartmentId);

            if (departmentMembership == null)
            {
                throw HttpStatusCode.Unauthorized.AsException();
            }

            if (departmentMembership.IsAdmin.HasValue)
            {
                result.Adm = departmentMembership.IsAdmin.Value;
            }

            if (department.ManagingUserId == UserId)
            {
                result.Adm = true;
            }

            bool isGroupAdmin = false;

            result.Grps = new List <GroupRight>();

            var group = _departmentGroupsService.GetGroupForUser(UserId, DepartmentId);

            if (group != null)
            {
                var groupRight = new GroupRight();
                groupRight.Gid = group.DepartmentGroupId;
                groupRight.Adm = group.IsUserGroupAdmin(UserId);

                if (groupRight.Adm)
                {
                    isGroupAdmin = true;
                }

                result.Grps.Add(groupRight);
            }

            var createCallPermission    = _permissionsService.GetPermisionByDepartmentType(DepartmentId, PermissionTypes.CreateCall);
            var viewPIIPermission       = _permissionsService.GetPermisionByDepartmentType(DepartmentId, PermissionTypes.ViewPersonalInfo);
            var createNotePermission    = _permissionsService.GetPermisionByDepartmentType(DepartmentId, PermissionTypes.CreateNote);
            var createMessagePermission = _permissionsService.GetPermisionByDepartmentType(DepartmentId, PermissionTypes.CreateMessage);

            result.VPii = _permissionsService.IsUserAllowed(viewPIIPermission, result.Adm, isGroupAdmin, roles);
            result.CCls = _permissionsService.IsUserAllowed(createCallPermission, result.Adm, isGroupAdmin, roles);
            result.ANot = _permissionsService.IsUserAllowed(createNotePermission, result.Adm, isGroupAdmin, roles);
            result.CMsg = _permissionsService.IsUserAllowed(createMessagePermission, result.Adm, isGroupAdmin, roles);

            if (!String.IsNullOrWhiteSpace(Config.FirebaseConfig.ResponderJsonFile) && !String.IsNullOrWhiteSpace(Config.FirebaseConfig.ResponderProjectEmail))
            {
                result.FirebaseApiToken = _firebaseService.CreateToken(UserId, null);
            }

            return(result);
        }
Example #16
0
        public ChatDataResult GetResponderChatSettings()
        {
            var result = new ChatDataResult();

            // Load Twilio configuration from Web.config
            var accountSid    = _appOptionsAccessor.Value.TwilioAccountSid;
            var apiKey        = _appOptionsAccessor.Value.TwilioApiKey;
            var apiSecret     = _appOptionsAccessor.Value.TwilioApiSecret;
            var ipmServiceSid = _appOptionsAccessor.Value.TwilioIpmServiceSid;

            // Create an Access Token generator
            var token = new AccessToken(accountSid, apiKey, apiSecret);

            token.Identity = UserId.ToString();

            // Create an IP messaging grant for this token
            var grant = new IpMessagingGrant();

            grant.EndpointId = $"ResponderDepChat:{UserId}:ResponderApp";
            grant.ServiceSid = ipmServiceSid;
            token.AddGrant(grant);

            var department = _departmentsService.GetDepartmentById(DepartmentId);
            var groups     = _departmentGroupsService.GetAllGroupsForDepartment(DepartmentId);

            result.Channels = SetupTwilioChatForDepartment(department, groups);

            result.Did  = department.DepartmentId;
            result.Name = department.Name;

            result.Groups = new List <GroupInfoResult>();
            if (department.IsUserAnAdmin(UserId))
            {
                foreach (var group in groups)
                {
                    result.Groups.Add(new GroupInfoResult()
                    {
                        Gid = group.DepartmentGroupId, Nme = group.Name
                    });
                }
            }
            else
            {
                var group = _departmentGroupsService.GetGroupForUser(UserId, DepartmentId);
                if (group != null)
                {
                    result.Groups.Add(new GroupInfoResult()
                    {
                        Gid = group.DepartmentGroupId, Nme = group.Name
                    });
                }
            }

            result.Token = token.ToJWT();

            return(result);
        }
Example #17
0
        public async Task <IActionResult> Index()
        {
            var model = new OrdersIndexView();

            model.YourOrders = new List <ResourceOrder>();
            model.YourOrders.AddRange((await _resourceOrdersService.GetAllOrdersByDepartmentId(DepartmentId)).OrderByDescending(x => x.OpenDate));

            model.OthersOrders = new List <ResourceOrder>();
            model.OthersOrders.AddRange(await _resourceOrdersService.GetOpenAvailableOrders(DepartmentId));

            model.Department  = _departmentsService.GetDepartmentById(DepartmentId);
            model.Coordinates = _departmentSettingsService.GetMapCenterCoordinates(model.Department);

            return(View(model));
        }
Example #18
0
        public IEnumerable <MessageResult> GetMessages()
        {
            var result     = new List <MessageResult>();
            var messages   = _messageService.GetInboxMessagesByUserId(UserId).OrderBy(x => x.SentOn).OrderByDescending(x => x.SentOn);
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            foreach (var m in messages)
            {
                var message = new MessageResult();

                message.Mid  = m.MessageId;
                message.Sub  = m.Subject;
                message.Bdy  = StringHelpers.StripHtmlTagsCharArray(m.Body).Truncate(100);
                message.Son  = m.SentOn.TimeConverter(department);
                message.SUtc = m.SentOn;
                message.Typ  = m.Type;

                if (!String.IsNullOrWhiteSpace(m.SendingUserId))
                {
                    message.Uid = m.SendingUserId;
                }

                var respose = m.MessageRecipients.FirstOrDefault(x => x.UserId == UserId);

                if (respose != null)
                {
                    if (String.IsNullOrWhiteSpace(respose.Response))
                    {
                        message.Rsp = true;
                    }

                    message.Ron = respose.ReadOn;
                }
                else
                {
                    message.Ron = m.ReadOn;
                }

                result.Add(message);
            }

            return(result);
        }
Example #19
0
        public StatusResult GetCurrentUserStatus()
        {
            var action     = _actionLogsService.GetLastActionLogForUser(UserId, DepartmentId);
            var userState  = _userStateService.GetLastUserStateByUserId(UserId);
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            var statusResult = new StatusResult
            {
                Act = (int)ActionTypes.StandingBy,
                Uid = UserId.ToString(),
                Ste = userState.State,
                Sts = userState.Timestamp.TimeConverter(department)
            };

            if (action == null)
            {
                statusResult.Ats = DateTime.UtcNow.TimeConverter(department);
            }
            else
            {
                statusResult.Act = action.ActionTypeId;
                statusResult.Ats = action.Timestamp.TimeConverter(department);

                if (action.DestinationId.HasValue)
                {
                    if (action.ActionTypeId == (int)ActionTypes.RespondingToScene)
                    {
                        statusResult.Did = action.DestinationId.Value;
                    }
                    else if (action.ActionTypeId == (int)ActionTypes.RespondingToStation)
                    {
                        statusResult.Did = action.DestinationId.Value;
                    }
                    else if (action.ActionTypeId == (int)ActionTypes.AvailableStation)
                    {
                        statusResult.Did = action.DestinationId.Value;
                    }
                }
            }

            return(statusResult);
        }
Example #20
0
        public async Task <ActionResult <ResponseDto <Department> > > GetDepartmentById(int id)
        {
            ResponseDto <Department> response = await _departmentsService.GetDepartmentById(id);

            if (response.HasErrors)
            {
                return(BadRequest(response));
            }

            return(Ok(response));
        }
Example #21
0
        public IActionResult ViewLogs(int unitId)
        {
            if (!_authorizationService.CanUserViewUnit(UserId, unitId))
            {
                Unauthorized();
            }

            var model = new ViewLogsView();

            model.Unit       = _unitsService.GetUnitById(unitId);
            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);

            if (model.Unit == null)
            {
                Unauthorized();
            }

            model.Logs = _unitsService.GetLogsForUnit(model.Unit.UnitId);

            return(View(model));
        }
Example #22
0
        public IActionResult Index()
        {
            var model = new UnitsIndexView();

            model.Department       = _departmentsService.GetDepartmentById(DepartmentId);
            model.CanUserAddUnit   = _limitsService.CanDepartentAddNewUnit(DepartmentId);
            model.Groups           = _departmentGroupsService.GetAllGroupsForDepartment(DepartmentId);
            model.Units            = _unitsService.GetUnitsForDepartment(DepartmentId);
            model.States           = _unitsService.GetAllLatestStatusForUnitsByDepartmentId(DepartmentId);
            model.UnitStatuses     = _customStateService.GetAllActiveUnitStatesForDepartment(DepartmentId);
            model.UnitCustomStates = new Dictionary <int, CustomState>();

            foreach (var unit in model.Units)
            {
                var type = _unitsService.GetUnitTypeByName(DepartmentId, unit.Type);
                if (type != null && type.CustomStatesId.HasValue)
                {
                    var customStates = _customStateService.GetCustomSateById(type.CustomStatesId.Value);

                    if (customStates != null)
                    {
                        model.UnitCustomStates.Add(unit.UnitId, customStates);
                    }
                }
            }

            return(View(model));
        }
Example #23
0
        public List <UnitStatusResult> GetUnitStatuses()
        {
            var results = new List <UnitStatusResult>();

            var units      = _unitsService.GetAllLatestStatusForUnitsByDepartmentId(DepartmentId);
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);

            /*
             * Parallel.ForEach(units, u =>
             * {
             *      var unitStatus = new UnitStatusResult();
             *      unitStatus.Uid = u.UnitId;
             *      unitStatus.Typ = u.State;
             *      unitStatus.Tmp = u.Timestamp.TimeConverter(department);
             *
             *      if (u.DestinationId.HasValue)
             *              unitStatus.Did = u.DestinationId.Value;
             *
             *      results.Add(unitStatus);
             * });
             */

            foreach (var u in units)
            {
                var unitStatus = new UnitStatusResult();
                unitStatus.Uid = u.UnitId;
                unitStatus.Typ = u.State;
                unitStatus.Tmp = u.Timestamp.TimeConverter(department);

                if (u.DestinationId.HasValue)
                {
                    unitStatus.Did = u.DestinationId.Value;
                }

                results.Add(unitStatus);
            }

            return(results);
        }
Example #24
0
        public IActionResult View(int id)
        {
            if (!_authorizationService.CanUserViewProtocol(UserId, id))
            {
                Unauthorized();
            }

            var model = new ViewProtocolModel();

            model.Protocol   = _protocolsService.GetProcotolById(id);
            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);

            return(View(model));
        }
Example #25
0
        public List <ProtocolResult> GetAllProtocols()
        {
            var results    = new List <ProtocolResult>();
            var department = _departmentsService.GetDepartmentById(DepartmentId, false);


            var protocols = _protocolsService.GetAllProtocolsForDepartment(DepartmentId);

            foreach (var p in protocols)
            {
                results.Add(ProtocolResult.Convert(p));
            }

            return(results);
        }
Example #26
0
        public IActionResult Index(string type, string category)
        {
            var model = new IndexView();

            model.Department = _departmentsService.GetDepartmentById(DepartmentId, false);
            model.Documents  = _documentsService.GetFilteredDocumentsByDepartmentId(DepartmentId, type, category);
            model.Categories = _documentsService.GetDistinctCategoriesByDepartmentId(DepartmentId);

            model.SelectedCategory = category;
            model.SelectedType     = type;

            model.UserId = UserId;

            return(View(model));
        }
Example #27
0
        public IActionResult View(int noteId)
        {
            ViewNoteView model = new ViewNoteView();

            var note = _notesService.GetNoteById(noteId);

            if (note.DepartmentId != DepartmentId)
            {
                Unauthorized();
            }

            model.Note       = note;
            model.Department = _departmentsService.GetDepartmentById(note.DepartmentId);

            return(View(model));
        }
Example #28
0
        public List <Training> GetTrainingsToNotify(DateTime currentTime)
        {
            var trainingsToNotify = new List <Training>();

            var trainings = _trainingRepository.GetAllTrainings();

            if (trainings != null && trainings.Any())
            {
                foreach (var training in trainings)
                {
                    if (!training.Notified.HasValue)
                    {
                        trainingsToNotify.Add(training);
                    }
                    else
                    {
                        Department d;
                        if (training.Department != null)
                        {
                            d = training.Department;
                        }
                        else
                        {
                            d = _departmentService.GetDepartmentById(training.DepartmentId);
                        }

                        if (d != null)
                        {
                            var localizedDate = TimeConverterHelper.TimeConverter(currentTime, d);
                            var setToNotify   = new DateTime(localizedDate.Year, localizedDate.Month, localizedDate.Day, 10, 0, 0, 0);

                            if (localizedDate == setToNotify.Within(TimeSpan.FromMinutes(13)) && training.ToBeCompletedBy.HasValue)
                            {
                                if (localizedDate.AddDays(1).ToShortDateString() == training.ToBeCompletedBy.Value.ToShortDateString())
                                {
                                    trainingsToNotify.Add(training);
                                }
                            }
                        }
                    }
                }
            }

            return(trainingsToNotify);
        }
        public Coordinates GetMapCenterCoordinatesForGroup(int departmentGroupId)
        {
            Coordinates coordinates = null;

            var departmentGroup = GetGroupById(departmentGroupId);
            var department      = _departmentsService.GetDepartmentById(departmentGroup.DepartmentId);

            if (departmentGroup.Address != null)
            {
                coordinates = new Coordinates();
                string coordinateString = _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3} {4}", departmentGroup.Address.Address1,
                                                                                                  departmentGroup.Address.City, departmentGroup.Address.State, departmentGroup.Address.PostalCode,
                                                                                                  departmentGroup.Address.Country));

                var coords = coordinateString.Split(char.Parse(","));
                coordinates.Latitude  = double.Parse(coords[0]);
                coordinates.Longitude = double.Parse(coords[1]);
            }

            if (coordinates == null && department.Address != null)
            {
                coordinates = new Coordinates();
                string coordinateString = _geoLocationProvider.GetLatLonFromAddress(string.Format("{0} {1} {2} {3} {4}", department.Address.Address1,
                                                                                                  department.Address.City, department.Address.State, department.Address.PostalCode, department.Address.Country));

                var coords = coordinateString.Split(char.Parse(","));
                coordinates.Latitude  = double.Parse(coords[0]);
                coordinates.Longitude = double.Parse(coords[1]);
            }

            var gpsCoordinates = _departmentSettingsService.GetBigBoardCenterGpsCoordinatesDepartment(departmentGroup.DepartmentId);

            if (coordinates == null && !string.IsNullOrWhiteSpace(gpsCoordinates))
            {
                coordinates = new Coordinates();

                var coords = gpsCoordinates.Split(char.Parse(","));
                coordinates.Latitude  = double.Parse(coords[0]);
                coordinates.Longitude = double.Parse(coords[1]);
            }


            return(coordinates);
        }
Example #30
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);
            //}
        }