Пример #1
0
        public async Task <HttpResponseMessage> UnassignVacancy(HttpRequestMessage request, int candidateId, int vacancyId)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var e = await eventService.RegisterCandidateFromVacancyUnassignment(vacancyId, candidateId, userId);

                var updatedCandidate = await candidateService.UnassignVacancy(candidateId, vacancyId, userId);

                unitOfWork.Save();

                var notification = await notificationService.CreateNotification(updatedCandidate.HRM,
                                                                                NotificationTypes.Update, new List <Event> {
                    e
                });

                if (NotificationsHub.IsConnected(updatedCandidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(new { candidateId, vacancyId }));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #2
0
        public void ParseContext()
        {
            string contextFile = @"..\..\..\Tracker.Core\TrackerContext.Generated.cs";
            var    result      = ContextParser.Parse(contextFile);

            Assert.IsNotNull(result);
        }
Пример #3
0
        public async Task <HttpResponseMessage> AddCandidate(HttpRequestMessage request, [FromBody] CandidateInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var candidate = Mapper.Map <CandidateInputDTO, Candidate>(value);

                candidate.HRM = userId;

                candidate.LastModifier = userId;

                var createdCandidate = await candidateService.Add(candidate, value.VacanciesIds)
                                       .ConfigureAwait(false);

                await eventService.RegisterCandidate(createdCandidate, userId);

                unitOfWork.Save();

                var candidateElastic = Mapper.Map <Candidate, CandidateElasticModel>(createdCandidate);
                await candidateElasticService.AddCandidateElastic(candidateElastic).ConfigureAwait(false);

                return(request.CreateResponse(HttpStatusCode.OK, createdCandidate.Id));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #4
0
        public DataServiceGen(
            DbContext dbContext,
            string projectPath,
            string projectName,
            JsonPropertyFormatEnum vmPropStyle,
            DIContainer dIContainer,
            bool activeCol    = true,
            bool requestScope = false
            )
        {
            ProjectPath = projectPath;

            if (ProjectPath[ProjectPath.Length - 1] == '\\' || ProjectPath[ProjectPath.Length - 1] == '/')
            {
                ProjectPath = ProjectPath.Remove(ProjectPath.Length - 1);
            }
            ProjectPath += "/";
            OutputPath   = ProjectPath;

            var curDir = Directory.GetCurrentDirectory() + '/';

            this.Style  = vmPropStyle;
            ProjectName = projectName;

            Data              = new ContextParser(dbContext, projectName).Data;
            Data.DIContainer  = dIContainer;
            Data.RequestScope = requestScope;
            Data.ActiveCol    = activeCol;
        }
Пример #5
0
 /// <summary>
 /// Takes a given child element (aChildElement) and parent constraint (aParentTemplateConstraint) and steps through the Children of the parent constraint
 /// to determine if any siblings of the child element exist.
 /// </summary>
 /// <param name="aChildElement">Target element that we need to locate siblings for</param>
 /// <param name="aParentTemplateConstraint">Parent Constraint of the aChildElement</param>
 /// <param name="aParentElement">Parent Element for the aChildElement</param>
 /// <param name="aAddedConstraints">Constraints that have already been added to the child collection, we don't need to parse these.</param>
 static private void AddSiblingElements(DocumentTemplateElement aChildElement, IConstraint aParentTemplateConstraint, DocumentTemplateElement aParentElement, Dictionary <DocumentTemplateElement, IConstraint> aConstraintMap)
 {
     //look at parent to get the siblings
     if (aParentTemplateConstraint.Children != null)
     {
         DocumentTemplateElement          parsedElement   = null;
         DocumentTemplateElementAttribute parsedAttribute = null;
         //walk through the siblings
         foreach (var sibling in aParentTemplateConstraint.Children)
         {
             //have we already added this constraint in a previous iteration (e.g. it's on the main path from the leaf to the root)
             if (sibling.IsBranchIdentifier && !aConstraintMap.ContainsValue(sibling))
             {
                 //parse the context
                 var cp = new ContextParser(sibling.Context);
                 cp.Parse(out parsedElement, out parsedAttribute);
                 //is this an element or an attribute?
                 if ((parsedElement != null) && (!string.IsNullOrEmpty(parsedElement.ElementName)))
                 {
                     parsedElement.IsBranchIdentifier = sibling.IsBranchIdentifier;
                     parsedElement.IsBranch           = sibling.IsBranch;
                     //element, let's add it to the parent element's children so it becomes a sibling of aChildElement
                     parsedElement.Value = sibling.Value;
                     aParentElement.AddElement(parsedElement);
                     AddBranchedAttributes(parsedElement, sibling);
                     aConstraintMap.Add(parsedElement, sibling);
                 }
             }
         }
     }
 }
Пример #6
0
        public async Task <HttpResponseMessage> Add(HttpRequestMessage request, [FromBody] VacancyInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var vacancy = Mapper.Map <VacancyInputDTO, Vacancy>(value);

                var createdVacancy = await vacancyService.Post(vacancy, value.Candidates, userId)
                                     .ConfigureAwait(false);

                await eventService.RegisterVacancy(createdVacancy, userId);

                unitOfWork.Save();

                var elasticVacancy = Mapper.Map <Vacancy, VacancyElasticModel>(createdVacancy);
                await vacancyElasticService.AddVacancyElastic(elasticVacancy);

                return(request.CreateResponse(HttpStatusCode.OK, createdVacancy.Id));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #7
0
        public async Task <HttpResponseMessage> UpdateStatus(HttpRequestMessage request, [FromBody] StatusUpdateInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var e = await eventService.RegisterCandidateStatusUpdate(value.EntityId, value.Status, userId);

                var candidate = await candidateService.UpdateStatus(value.EntityId, value.Status, userId);

                unitOfWork.Save();

                await candidateElasticService.UpdateStatusElastic(value.EntityId, value.Status).ConfigureAwait(false);

                var notification = await notificationService.CreateNotification(candidate.HRM,
                                                                                NotificationTypes.Update, new List <Event> {
                    e
                });

                if (NotificationsHub.IsConnected(candidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #8
0
        public async Task <HttpResponseMessage> AssignVacancies(HttpRequestMessage request, CandidatesVacanciesInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var result = await candidateService.AssignVacancies(value.Vacancies, value.Candidates, userId);

                unitOfWork.Save();

                foreach (var item in result.Events)
                {
                    var notification = await notificationService.CreateNotification(item.Key,
                                                                                    NotificationTypes.Update, item.Value);

                    if (NotificationsHub.IsConnected(item.Key))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
        public void ParseCodeIdentity()
        {
            var parser = new ContextParser(NullLoggerFactory.Instance);

            var sb = new StringBuilder();

            sb.AppendLine(@"using System;");
            sb.AppendLine(@"using Microsoft.EntityFrameworkCore;");
            sb.AppendLine(@"using Microsoft.EntityFrameworkCore.Metadata;");
            sb.AppendLine(@"");
            sb.AppendLine(@"namespace Tracker.Data");
            sb.AppendLine(@"{");
            sb.AppendLine(@"    public partial class TrackerContext : IdentityDbContext<User, Role, Guid, UserClaim, UserRole, UserLogin, RoleClaim, UserToken>");
            sb.AppendLine(@"    {");
            sb.AppendLine(@"        public TrackerContext(DbContextOptions<TrackerContext> options)");
            sb.AppendLine(@"            : base(options)");
            sb.AppendLine(@"        {");
            sb.AppendLine(@"        }");
            sb.AppendLine(@"");
            sb.AppendLine(@"        #region Generated Properties");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.Audit> Audits { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.Priority> Priorities { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.Role> Roles { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.Status> Statuses { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.Task> Tasks { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.User> Users { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.TaskExtended> TaskExtended { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.UserLogin> UserLogins { get; set; }");
            sb.AppendLine(@"        public virtual DbSet<Tracker.Data.Entities.UserRole> UserRoles { get; set; }");
            sb.AppendLine(@"        #endregion");
            sb.AppendLine(@"");
            sb.AppendLine(@"        protected override void OnModelCreating(ModelBuilder modelBuilder)");
            sb.AppendLine(@"        {");
            sb.AppendLine(@"            #region Generated Configuration");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.AuditMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.PriorityMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.RoleMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.StatusMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.TaskMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.UserMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.TaskExtendedMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.UserLoginMap());");
            sb.AppendLine(@"            modelBuilder.ApplyConfiguration(new Tracker.Data.Mapping.UserRoleMap());");
            sb.AppendLine(@"            #endregion");
            sb.AppendLine(@"        }");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"}");

            var result = parser.ParseCode(sb.ToString());

            result.Should().NotBeNull();
            result.Properties.Count.Should().Be(9);
            result.ContextClass.Should().Be("TrackerContext");
        }
        /// <summary>
        /// Uses back-tracing algorithm to go backwards through the tree
        /// Helper function which builds the full parent context for a given template constraint. For example, for the template constraint @code with cda:entryRelationship/cda:observation/cda:code[@code]
        /// this function returns the cda:entryRelationship/cda:observation/cda:code.
        /// </summary>
        /// <param name="aElement">current element to start from</param>
        /// <param name="aTemplateConstraint">constraint which will have its parent chain walked to form path</param>
        /// <param name="aIncludeElementInPath">determines whether we start the path with the element passed in (true) or its parent (false)</param>
        /// <returns>full context string</returns>
        public static string CreateFullParentContext(string aPrefix, IConstraint aTemplateConstraint)
        {
            if (aTemplateConstraint == null)
            {
                return(string.Empty);
            }

            DocumentTemplateElement          firstElement    = null;
            DocumentTemplateElement          newElement      = null;
            DocumentTemplateElement          previousElement = null;
            DocumentTemplateElementAttribute newAttribute    = null;
            IConstraint currentConstraint = aTemplateConstraint.Parent;

            while (currentConstraint != null)
            {
                //parse the context to determine whether this is element or attribute
                var contextParser = new ContextParser(currentConstraint.Context);
                contextParser.Parse(out newElement, out newAttribute);
                newElement.Attributes.Clear();
                if (currentConstraint.IsBranch) //if we hit a branch then we stop b/c we are in the branch's context
                {
                    break;
                }
                if (newElement == null)
                {
                    break;  //there is a broken chain, we have null parent
                }
                //add value and data type (if present)
                ConstraintToDocumentElementHelper.AddElementValueAndDataType(aPrefix, newElement, currentConstraint);
                //chain the previous element to the child collection of this new one
                if (previousElement != null)
                {
                    newElement.AddElement(previousElement);
                }
                //get the leaf node
                if (firstElement == null)
                {
                    firstElement = newElement;
                }
                previousElement = newElement;
                //walk the parent chain
                currentConstraint = currentConstraint.Parent;
            }
            if (firstElement == null)
            {
                return(string.Empty);
            }
            else
            {
                var contextBuilder = new ContextBuilder(firstElement, aPrefix);
                return(contextBuilder.GetFullyQualifiedContextString());
            }
        }
Пример #11
0
        public void ParseElementAndAttribute()
        {
            string context = "code/@code";
            DocumentTemplateElement          element   = null;
            DocumentTemplateElementAttribute attribute = null;
            var parser = new ContextParser(context);

            parser.Parse(out element, out attribute);
            Assert.IsNotNull(element, "No element was passed back from the parser.");
            Assert.IsTrue(element.ElementName == "code", "Element name was incorrect. Expected 'code', Actual '{0}'", element.ElementName);
            Assert.IsNotNull(attribute, "No attribute was passed back from the parser.");
            Assert.IsTrue(attribute.AttributeName == "code", "Element name was incorrect. Expected 'code', Actual '{0}'", attribute.AttributeName);
        }
Пример #12
0
        public void ParseMultipleElements()
        {
            string context = "entry/observation";
            DocumentTemplateElement          element   = null;
            DocumentTemplateElementAttribute attribute = null;
            var parser = new ContextParser(context);

            parser.Parse(out element, out attribute);
            Assert.IsNotNull(element, "No element was passed back from the parser.");
            Assert.IsTrue(element.ElementName == "observation", "Element name was incorrect. Expected 'observation', Actual '{0}'", element.ElementName);

            Assert.IsNotNull(element.ParentElement, "No parent element was passed back from the parser.");
            Assert.IsTrue(element.ParentElement.ElementName == "entry", "Element name was incorrect. Expected 'entry', Actual '{0}'", element.ElementName);

            Assert.IsNull(attribute, "An attribute was passed back from the parser. Exected null.");
        }
        public void ParseNonContextFile()
        {
            var parser = new ContextParser(NullLoggerFactory.Instance);

            var sb = new StringBuilder();

            sb.AppendLine(@"namespace InstructorIQ.Core.Options");
            sb.AppendLine(@"{");
            sb.AppendLine(@"    public class HostingConfiguration : Options<User>");
            sb.AppendLine(@"    {");
            sb.AppendLine(@"        public string Version { get; set; }");
            sb.AppendLine(@"    }");
            sb.AppendLine(@"}");

            var result = parser.ParseCode(sb.ToString());

            result.Should().BeNull();
        }
Пример #14
0
        public async Task <HttpResponseMessage> MarkAsRead(HttpRequestMessage request, List <int> ids)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                await notificationService.MarkAsRead(userId, ids);

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(ids));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #15
0
        static void Main(string[] args)
        {
            var connectionString   = "Data Source=CO-YAR-WS208;Initial Catalog=OnlineShop;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework";
            var currentTable       = "dbo.Orders";
            var userTable          = "dbo.Employees";
            var rowIdentifierKeys  = "[id][1][int]";
            var userIdentifierKeys = "[id][1][int]";
            var expressions        = "12.4 / 2 = 1.24";


            //ContextParser.ConnectionString = connectionString;
            //var result1 = ContextParser.ExecuteStaticPredicate(expressions, 1, true, 1, "fdfd", DateTime.Now, DateTimeOffset.MinValue, TimeSpan.MinValue, new Guid(),
            //    1, true, 1, "fdfd", DateTime.Now, DateTimeOffset.MinValue, TimeSpan.MinValue, new Guid());

            var result = ContextParser.ExecutePredicate(currentTable, userTable, expressions, rowIdentifierKeys,
                                                        userIdentifierKeys);

            Console.WriteLine(result);
            Console.ReadKey();
        }
Пример #16
0
        public async Task <HttpResponseMessage> AddGeneralInterview(HttpRequestMessage request, [FromBody] GeneralInterviewInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var interview = Mapper.Map <GeneralInterviewInDTO, GeneralInterview>(value);

                interview.HRM = userId;

                var createdInterview = await interviewService.AddGeneralInterview(interview);

                var e = await eventService.RegisterGeneralInterview(createdInterview, userId);

                unitOfWork.Save();

                if (createdInterview.Interviewer.HasValue)
                {
                    var notification = await notificationService.CreateNotification(createdInterview.Interviewer.Value,
                                                                                    NotificationTypes.Interview, new List <Event> {
                        e
                    });

                    if (NotificationsHub.IsConnected(createdInterview.Interviewer.Value))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #17
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, [FromBody] CandidateInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var candidate = Mapper.Map <CandidateInputDTO, Candidate>(value);

                candidate.LastModifier = userId;

                var events = await eventService.RegisterCandidateUpdate(candidate, userId);

                var updatedCandidate = await candidateService.Update(candidate, value.VacanciesIds)
                                       .ConfigureAwait(false);

                unitOfWork.Save();

                var candidateElasticModel = Mapper.Map <Candidate, CandidateElasticModel>(updatedCandidate);
                await candidateElasticService.UpdateCandidateElastic(candidateElasticModel);

                var notification = await notificationService.CreateNotification(updatedCandidate.HRM,
                                                                                NotificationTypes.Update, events);

                if (NotificationsHub.IsConnected(updatedCandidate.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #18
0
        public async Task <HttpResponseMessage> UpdateTech(HttpRequestMessage request, [FromBody] InterviewUpdateDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var techInterview = Mapper.Map <InterviewUpdateDTO, TechInterview>(value);

                techInterview.HRM = userId;

                var eventsForNotification = await eventService.RegisterTechInterviewUpdate(techInterview, userId);

                var updatedInterview = await interviewService.UpdateTechInterview(techInterview);

                unitOfWork.Save();

                if (updatedInterview.Interviewer.HasValue)
                {
                    var notification = await notificationService.CreateNotification(updatedInterview.Interviewer.Value,
                                                                                    NotificationTypes.Update, eventsForNotification);

                    if (NotificationsHub.IsConnected(updatedInterview.Interviewer.Value))
                    {
                        await NotificationsHub.PushNotification(notification);
                    }
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #19
0
 /// <summary>
 /// Helper method which steps through the children for a given constraint (aTemplateConstraint) and attaches any attributes to the
 /// given element (aElement)).
 /// </summary>
 /// <param name="aElement">Element to add the attributes to</param>
 /// <param name="aTemplateConstraint">Constraint to walk the children to find attributes</param>
 static private void AddBranchedAttributes(DocumentTemplateElement aElement, IConstraint aTemplateConstraint)
 {
     if (aTemplateConstraint.Children != null)
     {
         DocumentTemplateElement          parsedElement   = null;
         DocumentTemplateElementAttribute parsedAttribute = null;
         foreach (var child in aTemplateConstraint.Children)
         {
             var cp = new ContextParser(child.Context);
             cp.Parse(out parsedElement, out parsedAttribute);
             if (parsedElement != null)
             {
                 parsedElement.IsBranch           = child.IsBranch;
                 parsedElement.IsBranchIdentifier = child.IsBranchIdentifier;
             }
             if (parsedAttribute != null) //we are only looking for attributes
             {
                 parsedAttribute.SingleValue = child.Value;
                 aElement.AddAttribute(parsedAttribute);
             }
         }
     }
 }
Пример #20
0
        public async Task <HttpResponseMessage> Update(HttpRequestMessage request, [FromBody] VacancyInputDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var vacancy = Mapper.Map <VacancyInputDTO, Vacancy>(value);

                var e = await eventService.RegisterVacancyUpdate(vacancy, userId);

                var updatedVacancy = await vacancyService.Update(vacancy, value.Candidates, userId)
                                     .ConfigureAwait(false);

                unitOfWork.Save();

                var elasticVacancy = Mapper.Map <Vacancy, VacancyElasticModel>(updatedVacancy);
                await vacancyElasticService.UpdateVacancyElastic(elasticVacancy);

                var notification = await notificationService.CreateNotification(updatedVacancy.HRM,
                                                                                NotificationTypes.Update, e);

                if (NotificationsHub.IsConnected(updatedVacancy.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #21
0
        public async Task <HttpResponseMessage> SetFeedbackGeneral(HttpRequestMessage request, [FromBody] GeneralInterviewFeedbackInDTO value)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var generalInterview = Mapper.Map <GeneralInterviewFeedbackInDTO, GeneralInterview>(value);

                var updatedInterview = await interviewService.SetGeneralInterviewFeedback(generalInterview);

                var events = await eventService.RegisterGeneralInterviewFeedback(updatedInterview, userId);

                unitOfWork.Save();

                await notificationService.MarkAsRead(userId, new List <int> {
                    value.NotificationId
                });

                var notification = await notificationService.CreateNotification(updatedInterview.HRM,
                                                                                NotificationTypes.Update, events);

                if (NotificationsHub.IsConnected(updatedInterview.HRM))
                {
                    await NotificationsHub.PushNotification(notification);
                }

                unitOfWork.Save();

                return(request.CreateResponse(HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(value));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #22
0
        public async Task <HttpResponseMessage> GetUnseenOfType(HttpRequestMessage request, int type, int skip, int amount)
        {
            try
            {
                var userId = ContextParser.GetUserId(request.GetRequestContext());

                var notifications = await notificationService.GetUnseenOfType(userId, type, skip, amount);

                var result = Mapper.Map <ICollection <NotificationDTO> >(notifications);

                for (var i = 0; i < notifications.Count; i++)
                {
                    result.ElementAt(i).Title = NotificationInfoStringBuilder.GetNotificationTitle(notifications.ElementAt(i));
                }

                return(request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                logger.Error(ex, JsonConvert.SerializeObject(new { type, skip, amount }));

                return(request.CreateResponse(HttpStatusCode.InternalServerError));
            }
        }
Пример #23
0
        static public void ParseContextForElementAndAttribute(IConstraint aConstraint, out DocumentTemplateElement aElement, out DocumentTemplateElementAttribute aAttribute)
        {
            var cp = new ContextParser(aConstraint.Context);

            cp.Parse(out aElement, out aAttribute);
        }