internal void NotificationRead(int id, int id1, int projectId) { var notification = Context.AssociatedProjectNotifications.FirstOrDefault(x => x.NotificationId == id && x.UserAccountId == id1 && x.ProjectId == projectId && x.IsRead != 1); if (notification != null) { notification.NewNotification = 0; notification.IsRead = 1; Context.Attach(notification); Context.Update(notification); Context.SaveChanges(); } var personalMessage = Context.AssociatedUserNotifications.FirstOrDefault(x => x.NotificationId == id && x.UserId == id1 && x.IsRead != 1); if (personalMessage != null) { personalMessage.NewNotification = 0; personalMessage.IsRead = 1; Context.Attach(personalMessage); Context.Update(personalMessage); Context.SaveChanges(); } }
internal void AddNewUserNote(IncomingNoteRequest note, int id) { var currentNote = Context.UserNotes.Add(new UserNotes { Content = note.Content, DateOfMessage = DateTime.Now, NoteBackground = note.Background, NoteForeground = note.FontColor }); Context.SaveChanges(); Context.AssociatedAccountNotes.Add(new AssociatedAccountNotes { NoteId = currentNote.Entity.Id, ProjectId = note.ProjectId, UserAccountId = id }); Context.SaveChanges(); }
private AssociatedProjectApiKeys GenerateProjectKey(string keyName, int projectId) { var getKey = Context.ApiKeys.FirstOrDefault(x => x.FeatureName == keyName); if (getKey == null) { return(null); } var projectKey = Context.AssociatedProjectApiKeys.Add(new AssociatedProjectApiKeys { KeyId = getKey.Id, ProjectId = projectId, ApiSecret = $"{Guid.NewGuid()}{DateTime.Now.Ticks}" }); Context.SaveChanges(); projectKey.Entity.Key = getKey; return(projectKey.Entity); }
internal void AddNewDocumentationCategory(IncomingIdRequest request) { var getDocumentation = Context.Documentation.FirstOrDefault(x => x.ProjectId == request.ProjectId); Context.DocumentationCategory.Add(new DocumentationCategory { CategoryName = request.Phase, DocumentationId = getDocumentation.Id, }); Context.SaveChanges(); }
internal void AssociatedChangelogItems(IncomingGenerateChangelog changelog) { var currentChangelog = Context.Changelogs.Add(new Changelogs { DayOfLog = DateTime.Now.Day, LogDetails = changelog.Chagelog }); Context.SaveChanges(); Context.AssociatedProjectChangelogs.Add(new AssociatedProjectChangelogs { CurrentMonth = DateTime.Now.Month, ProjectId = changelog.ProjectId, LogYear = DateTime.Now.Year, LogId = currentChangelog.Entity.Id }); Context.SaveChanges(); changelog.Items.ForEach(x => { Context.AssociatedWorkItemChangelogs.Add(new AssociatedWorkItemChangelogs { LogId = currentChangelog.Entity.Id, WorkitemId = x.Id, ProjectId = changelog.ProjectId }); Context.SaveChanges(); }); }
internal PublicMessages AddNewFeedback(IncomingPublicMessage newMessage) { var message = Context.PublicMessages.Add(new PublicMessages { DateOfMessage = DateTime.Now, SenderName = newMessage.SenderName, MessageContent = newMessage.MessageContent }); Context.SaveChanges(); var association = Context.AssociatedProjectFeedback.Add(new AssociatedProjectFeedback { ProjectId = newMessage.ProjectId, MessageId = message.Entity.Id, Rating = 6 }); Context.SaveChanges(); return(message.Entity); }
public static WorkItem AddNewWorkItem(IncomingWorkItem currentItem, RokonocontrolContext Context, IConfiguration configuration, int userId) { var currentUser = "******"; var relationshipId = default(int); currentItem.SelectedChildren.ForEach(x => { var relId = int.Parse(x.RelationShipId); var getItem = Context.WorkItemRelations.FirstOrDefault(y => y.Id == relId); if (getItem.RelationName == "Parent") { relationshipId = getItem.Id; } }); if (currentItem.FoundInBuild == null) { currentItem.FoundInBuild = "0"; } if (currentItem.ResolvedInBuild == null) { currentItem.ResolvedInBuild = "0"; } var databaseItem = new WorkItem(); databaseItem.Title = currentItem.Title; if (currentItem.AssignedUser != 0) { var userData = Context.UserAccounts.FirstOrDefault(x => x.Id == currentItem.AssignedUser); databaseItem.AssignedAccount = currentItem.AssignedUser; currentUser = $"{userData.FirstName} {userData.LastName}"; } if (!string.IsNullOrEmpty(currentItem.SystemDesignInfo)) { databaseItem.SystemDesignInfo = currentItem.SystemDesignInfo; } if (currentItem.WorktItemType != 0) { databaseItem.WorkItemTypeId = currentItem.WorktItemType; } if (!string.IsNullOrEmpty(currentItem.State)) { databaseItem.StateId = int.Parse(currentItem.State); } if (!string.IsNullOrEmpty(currentItem.ItemReason)) { databaseItem.Reason = int.Parse(currentItem.ItemReason); } if (!string.IsNullOrEmpty(currentItem.ItemIteration)) { databaseItem.Iteration = int.Parse(currentItem.ItemIteration); } if (!string.IsNullOrEmpty(currentItem.ItemArea)) { databaseItem.AreaId = int.Parse(currentItem.ItemArea); } if (currentItem.WorktItemType == 1) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.ItemActivity)) { databaseItem.Activity = int.Parse(currentItem.ItemActivity); } databaseItem.RepoSteps = currentItem.RepoSteps; databaseItem.SystemInfo = currentItem.SystemInfo; if (!string.IsNullOrEmpty(currentItem.FoundInBuild)) { databaseItem.FoundInBuild = int.Parse(currentItem.FoundInBuild); } if (!string.IsNullOrEmpty(currentItem.ResolvedInBuild)) { databaseItem.IntegratedInBuild = int.Parse(currentItem.ResolvedInBuild); } databaseItem.Compleated = currentItem.ItemCompleated; databaseItem.Remaining = currentItem.ItemRemaining; databaseItem.OriginEstitame = currentItem.OriginalEstimate; if (!string.IsNullOrEmpty(currentItem.ItemSeverity)) { databaseItem.Severity = int.Parse(currentItem.ItemSeverity); } databaseItem.ParentId = relationshipId; } else if (currentItem.WorktItemType == 2) { databaseItem.AcceptanceCriteria = currentItem.AcceptanceCriteria; databaseItem.Description = currentItem.Description; databaseItem.StartDate = currentItem.StartDate == null ? DateTime.Now : currentItem.StartDate; databaseItem.EndDate = currentItem.EndDate == null ? DateTime.Now : currentItem.EndDate; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } databaseItem.Effort = currentItem.Effort; databaseItem.BusinessValue = currentItem.BusinessValue; databaseItem.TimeCapacity = currentItem.TimeCriticality; databaseItem.ValueAreaId = int.Parse(currentItem.ValueAreId); } else if (currentItem.WorktItemType == 5) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.RiskId)) { databaseItem.RiskId = int.Parse(currentItem.RiskId); } databaseItem.Effort = currentItem.Effort; databaseItem.BusinessValue = currentItem.BusinessValue; databaseItem.TimeCapacity = currentItem.TimeCriticality; if (!string.IsNullOrEmpty(currentItem.ValueAreId)) { databaseItem.ValueAreaId = int.Parse(currentItem.ValueAreId); } databaseItem.StartDate = currentItem.StartDate == null ? DateTime.Now : currentItem.StartDate; databaseItem.EndDate = currentItem.EndDate == null ? DateTime.Now : currentItem.EndDate; if (!string.IsNullOrEmpty(currentItem.Description)) { databaseItem.Description = currentItem.Description; } } else if (currentItem.WorktItemType == 6) { databaseItem.StackRank = currentItem.Rank; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } databaseItem.DueDate = currentItem.DueDate == null ? DateTime.Now : currentItem.DueDate;; } else if (currentItem.WorktItemType == 3) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.ItemActivity)) { databaseItem.Activity = int.Parse(currentItem.ItemActivity); } databaseItem.OriginEstitame = currentItem.OriginalEstimate; databaseItem.Remaining = currentItem.ItemRemaining; databaseItem.Compleated = currentItem.ItemCompleated; if (!string.IsNullOrEmpty(currentItem.ResolvedInBuild)) { databaseItem.IntegratedInBuild = int.Parse(currentItem.ResolvedInBuild); } databaseItem.Description = currentItem.Description; } else if (currentItem.WorktItemType == 7) { databaseItem.StoryPoints = currentItem.StoryPoints; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { databaseItem.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.RiskId)) { databaseItem.RiskId = int.Parse(currentItem.RiskId); } if (!string.IsNullOrEmpty(currentItem.ValueAreId)) { databaseItem.ValueAreaId = int.Parse(currentItem.ValueAreId); } databaseItem.Description = currentItem.Description; databaseItem.AcceptanceCriteria = currentItem.AcceptanceCriteria; } if (float.TryParse(databaseItem.Compleated, out var complete)) { databaseItem.Remaining = "0"; databaseItem.Remaining = "0"; } databaseItem.StartDate = currentItem.StartDate.Ticks == 0 ? DateTime.Now : currentItem.StartDate; databaseItem.EndDate = currentItem.EndDate.Ticks == 0 ? DateTime.Now : currentItem.EndDate; databaseItem.DueDate = currentItem.DueDate.Ticks == 0 ? DateTime.Now : currentItem.DueDate; var item = Context.WorkItem.Add(databaseItem); Context.SaveChanges(); //Associated with parent id in case its being added as a child of another item if (currentItem.ParentId != 0) { Context.AssociatedWrorkItemChildren.Add(new AssociatedWrorkItemChildren { RelationType = databaseItem.RelationId, WorkItemId = currentItem.ParentId, WorkItemChildId = databaseItem.Id }); Context.SaveChanges(); } var pBoard = Context.AssociatedProjectBoards.Include(x => x.Board).FirstOrDefault(x => x.ProjectId == currentItem.ProjectId && x.Board.BoardName == "Open"); if (pBoard != null) { Context.AssociatedBoardWorkItems.Add(new AssociatedBoardWorkItems { BoardId = pBoard.BoardId.Value, WorkItemId = item.Entity.Id, ProjectId = currentItem.ProjectId }); Context.SaveChanges(); } if (relationshipId == default(int)) { databaseItem.ParentId = item.Entity.Id; Context.Attach(item.Entity); Context.Entry(item.Entity).Property("ParentId").IsModified = true; Context.SaveChanges(); } currentItem.SelectedChildren.ForEach(x => { var relId = int.Parse(x.RelationShipId); var getItem = Context.WorkItemRelations.FirstOrDefault(y => y.Id == relId); if (getItem.RelationName != "Parent") { Context.AssociatedWrorkItemChildren.Add(new AssociatedWrorkItemChildren { WorkItemChildId = x.WorkItemId, WorkItemId = item.Entity.Id, RelationType = relId }); Context.SaveChanges(); } else { var dbItem = Context.WorkItem.FirstOrDefault(y => y.Id == x.WorkItemId); item.Entity.ParentId = dbItem.Id; Context.Attach(item.Entity); Context.Update(item.Entity); Context.SaveChanges(); } }); var notification = Context.Notifications.Add(new Notifications { DateOfMessage = DateTime.Now, Content = $"Work Item Title:{item.Entity.Title} ID:{item.Entity.Id}- Has been created and assigned to {currentUser}", NotificationType = 3, WorkItemRelationid = currentItem.WorkItemId, }); Context.SaveChanges(); var projectUsers = Context.AssociatedProjectMembers.Where(x => x.ProjectId == currentItem.ProjectId).ToList(); //Todo: Thows duplicate error, database mapping should be reworked to allow cross project notification based on user view projectUsers.ForEach(x => { Context.AssociatedProjectNotifications.Add(new AssociatedProjectNotifications { NotificationId = notification.Entity.Id, ProjectId = currentItem.ProjectId, NewNotification = 1, IsRead = 0, UserAccountId = x.UserAccountId }); Context.SaveChanges(); }); if (currentItem.SelectedFiles != null) { currentItem.SelectedFiles.ForEach(x => { var fileType = FileProcessor.GetImageType(x); var files = Context.SystemFiles.Add(new SystemFiles { DateOfMessage = DateTime.Now, FileLocation = x, FileType = fileType == "" ? 2 : 1, SenderName = "System" }); Context.SaveChanges(); Context.AssociatedWorkItemFiles.Add(new AssociatedWorkItemFiles { FileId = files.Entity.Id, WorkItemId = item.Entity.Id }); Context.SaveChanges(); }); } return(databaseItem); }
internal static bool UpdateWorkItem(IncomingWorkItem currentItem, RokonocontrolContext Context) { var dbVersion = Context.WorkItem.FirstOrDefault(x => x.Id == currentItem.WorkItemId); Context.Attach(dbVersion); var relationshipId = default(int); if (currentItem.SelectedChildren != null) { currentItem.SelectedChildren.ForEach(x => { if (x.RelationShipId != null) { var relId = int.Parse(x.RelationShipId); var getItem = Context.WorkItemRelations.FirstOrDefault(y => y.Id == relId); if (getItem.RelationName == "Parent") { relationshipId = getItem.Id; } } }); } if (currentItem.FoundInBuild == null) { currentItem.FoundInBuild = "0"; } if (currentItem.ResolvedInBuild == null) { currentItem.ResolvedInBuild = "0"; } dbVersion.Title = currentItem.Title; if (currentItem.AssignedUser != 0) { dbVersion.AssignedAccount = currentItem.AssignedUser; } if (currentItem.WorktItemType != 0) { dbVersion.WorkItemTypeId = currentItem.WorktItemType; } if (!string.IsNullOrEmpty(currentItem.State)) { dbVersion.StateId = int.Parse(currentItem.State); } if (!string.IsNullOrEmpty(currentItem.ItemReason)) { dbVersion.Reason = int.Parse(currentItem.ItemReason); } if (!string.IsNullOrEmpty(currentItem.ItemIteration)) { dbVersion.Iteration = int.Parse(currentItem.ItemIteration); } if (!string.IsNullOrEmpty(currentItem.ItemArea)) { dbVersion.AreaId = int.Parse(currentItem.ItemArea); } if (!string.IsNullOrEmpty(currentItem.SystemDesignInfo)) { dbVersion.SystemDesignInfo = currentItem.SystemDesignInfo; } if (currentItem.WorktItemType == 1) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.ItemActivity)) { dbVersion.Activity = int.Parse(currentItem.ItemActivity); } dbVersion.RepoSteps = currentItem.RepoSteps; dbVersion.SystemInfo = currentItem.SystemInfo; if (!string.IsNullOrEmpty(currentItem.FoundInBuild)) { dbVersion.FoundInBuild = int.Parse(currentItem.FoundInBuild); } if (!string.IsNullOrEmpty(currentItem.ResolvedInBuild)) { dbVersion.IntegratedInBuild = int.Parse(currentItem.ResolvedInBuild); } dbVersion.Compleated = currentItem.ItemCompleated; dbVersion.Remaining = currentItem.ItemRemaining; dbVersion.OriginEstitame = currentItem.OriginalEstimate; if (!string.IsNullOrEmpty(currentItem.ItemSeverity)) { dbVersion.Severity = int.Parse(currentItem.ItemSeverity); } dbVersion.ParentId = relationshipId; } else if (currentItem.WorktItemType == 2) { dbVersion.AcceptanceCriteria = currentItem.AcceptanceCriteria; dbVersion.Description = currentItem.Description; dbVersion.StartDate = currentItem.StartDate == null ? DateTime.Now : currentItem.StartDate; dbVersion.EndDate = currentItem.EndDate == null ? DateTime.Now : currentItem.EndDate; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } dbVersion.Effort = currentItem.Effort; dbVersion.BusinessValue = currentItem.BusinessValue; dbVersion.TimeCapacity = currentItem.TimeCriticality; dbVersion.ValueAreaId = int.Parse(currentItem.ValueAreId); } else if (currentItem.WorktItemType == 5) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.RiskId)) { dbVersion.RiskId = int.Parse(currentItem.RiskId); } dbVersion.Effort = currentItem.Effort; dbVersion.BusinessValue = currentItem.BusinessValue; dbVersion.TimeCapacity = currentItem.TimeCriticality; if (!string.IsNullOrEmpty(currentItem.ValueAreId)) { dbVersion.ValueAreaId = int.Parse(currentItem.ValueAreId); } dbVersion.StartDate = currentItem.StartDate == null ? DateTime.Now : currentItem.StartDate; dbVersion.EndDate = currentItem.EndDate == null ? DateTime.Now : currentItem.EndDate; if (!string.IsNullOrEmpty(currentItem.Description)) { dbVersion.Description = currentItem.Description; } } else if (currentItem.WorktItemType == 6) { dbVersion.StackRank = currentItem.Rank; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } dbVersion.DueDate = currentItem.DueDate == null ? DateTime.Now : currentItem.DueDate; } else if (currentItem.WorktItemType == 3) { if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.ItemActivity)) { dbVersion.Activity = int.Parse(currentItem.ItemActivity); } dbVersion.OriginEstitame = currentItem.OriginalEstimate; dbVersion.Remaining = currentItem.ItemRemaining; dbVersion.Compleated = currentItem.ItemCompleated; if (!string.IsNullOrEmpty(currentItem.ResolvedInBuild)) { dbVersion.IntegratedInBuild = int.Parse(currentItem.ResolvedInBuild); } dbVersion.Description = currentItem.Description; } else if (currentItem.WorktItemType == 7) { dbVersion.StoryPoints = currentItem.StoryPoints; if (!string.IsNullOrEmpty(currentItem.ItemPriority)) { dbVersion.PriorityId = int.Parse(currentItem.ItemPriority); } if (!string.IsNullOrEmpty(currentItem.RiskId)) { dbVersion.RiskId = int.Parse(currentItem.RiskId); } if (!string.IsNullOrEmpty(currentItem.ValueAreId)) { dbVersion.ValueAreaId = int.Parse(currentItem.ValueAreId); } dbVersion.Description = currentItem.Description; dbVersion.AcceptanceCriteria = currentItem.AcceptanceCriteria; } dbVersion.StartDate = currentItem.StartDate.Ticks == 0 ? DateTime.Now : currentItem.StartDate; dbVersion.EndDate = currentItem.EndDate.Ticks == 0 ? DateTime.Now : currentItem.EndDate; dbVersion.DueDate = currentItem.DueDate.Ticks == 0 ? DateTime.Now : currentItem.DueDate; Context.Entry(dbVersion).State = EntityState.Modified; Context.SaveChanges(); currentItem.SelectedChildren.ForEach(x => { if (x.RelationShipId != null) { var relId = int.Parse(x.RelationShipId); var getItem = Context.WorkItemRelations.FirstOrDefault(y => y.Id == relId); if (getItem.RelationName != "Parent") { Context.AssociatedWrorkItemChildren.Add(new AssociatedWrorkItemChildren { WorkItemChildId = x.WorkItemId, WorkItemId = currentItem.WorkItemId, RelationType = relId }); Context.SaveChanges(); } else { var dbItem = Context.WorkItem.FirstOrDefault(y => y.Id == x.WorkItemId); dbItem.ParentId = currentItem.WorkItemId; Context.Attach(dbItem); Context.Update(dbItem); Context.SaveChanges(); } } }); var notification = Context.Notifications.Add(new Notifications { DateOfMessage = DateTime.Now, Content = $"Work Item Title:{dbVersion.Title} ID:{dbVersion.Id}- Has been updated", NotificationType = 4, WorkItemRelationid = currentItem.WorkItemId }); Context.SaveChanges(); var projectUsers = Context.AssociatedProjectMembers.Where(x => x.ProjectId == currentItem.ProjectId).ToList(); //Todo: Thows duplicate error, database mapping should be reworked to allow cross project notification based on user view projectUsers.ForEach(x => { Context.AssociatedProjectNotifications.Add(new AssociatedProjectNotifications { NotificationId = notification.Entity.Id, ProjectId = currentItem.ProjectId, NewNotification = 1, IsRead = 0, UserAccountId = x.UserAccountId }); Context.SaveChanges(); }); var prevList = Context.AssociatedWorkItemFiles.Where(x => x.WorkItemId == dbVersion.Id).ToList(); Context.RemoveRange(prevList); Context.SaveChanges(); if (currentItem.SelectedFiles != null) { currentItem.SelectedFiles.ForEach(x => { var fileId = default(int); if (Context.SystemFiles.FirstOrDefault(y => y.FileLocation == x) == null) { var fileType = FileProcessor.GetImageType(x); var files = Context.SystemFiles.Add(new SystemFiles { DateOfMessage = DateTime.Now, FileLocation = x, FileType = fileType == "" ? 2 : 1, SenderName = "System" }); Context.SaveChanges(); fileId = files.Entity.Id; } else { var file = Context.SystemFiles.FirstOrDefault(y => y.FileLocation == x); fileId = file.Id; } Context.AssociatedWorkItemFiles.Add(new AssociatedWorkItemFiles { FileId = fileId, WorkItemId = dbVersion.Id }); Context.SaveChanges(); }); } return(true); }
internal void UpdateWidgetResized(IncomingIdRequest request) { var associationVal = int.Parse(request.__RequestVerificationToken.Replace("layout_", "")); var values = request.Phase.Split(","); var association = Context.AssociatedUserDashboardPremade.FirstOrDefault(x => x.Id == associationVal); association.DataCol = int.Parse(values[0] == "NaN" ? "0" : values[0]); association.DataRow = int.Parse(values[1] == "NaN" ? "0" : values[1]); association.DataSizeX = int.Parse(values[2] == "NaN" ? "0" : values[2]); association.DataSizeY = int.Parse(values[3] == "NaN" ? "0" : values[3]); Context.Attach(association); Context.Update(association); Context.SaveChanges(); }
internal string AddChatRoomMessage(IncomingChatMessage messageData, int sender) { var chatRoom = Context.ChatChannels.FirstOrDefault(x => x.Id == messageData.ActiveRoom); if (chatRoom == null && messageData.IsPersonal == 0) { return(string.Empty); } if (messageData.IsPersonal == 0) { var projectUsers = Context.AssociatedProjectMembers.Where(x => x.ProjectId == messageData.ProjectId).ToList(); projectUsers.ForEach(x => { if (Context.AssociatedUserChatNotifications.FirstOrDefault(y => y.ChatChannelId == messageData.ActiveRoom && y.ProjectId == x.ProjectId && y.UserId == x.UserAccountId) == null) { Context.AssociatedUserChatNotifications.Add(new AssociatedUserChatNotifications { ChatChannelId = chatRoom.Id, ProjectId = messageData.ProjectId, UserId = x.UserAccountId }); Context.SaveChanges(); } }); } else { var senderName = Context.UserAccounts.FirstOrDefault(x => x.Id == sender).Email; var notification = Context.Notifications.Add(new Notifications { Content = $"{senderName} has sent you a new message.", NotificationType = 1, DateOfMessage = DateTime.Now, }); Context.SaveChanges(); Context.AssociatedUserNotifications.Add(new AssociatedUserNotifications { NewNotification = 1, IsRead = 0, UserId = messageData.ReciverId, NotificationId = notification.Entity.Id }); Context.SaveChanges(); } var email = Context.UserAccounts.FirstOrDefault(x => x.Id == sender).Email; var message = Context.PublicMessages.Add(new PublicMessages { IsNew = 1, SenderId = sender, MessageContent = messageData.Message, DateOfMessage = DateTime.Now, SenderName = email }); Context.SaveChanges(); if (messageData.IsPersonal == 0) { Context.AssociatedChatChannelMessages.Add(new AssociatedChatChannelMessages { ChatChannelId = messageData.ActiveRoom, PublicMessageId = message.Entity.Id, }); } else { Context.AssociatedChatPersonalMessages.Add(new AssociatedChatPersonalMessages { ProjectId = messageData.ProjectId, PublicMessageId = message.Entity.Id, SenderId = sender, ReciverId = messageData.ReciverId, }); } Context.SaveChanges(); return(email); }
private int GenerateDefaultDashboard(int userId, int projectId) { var dashboard = Context.UserDashboards.Add(new UserDashboards { DashboardName = "Default Dashboard", DateOfDashboard = DateTime.Now, ProjectId = projectId, UserId = userId }); Context.SaveChanges(); return(dashboard.Entity.Id); }