/// <summary> /// Method definition to add/update story /// </summary> /// <param name="newStoryDetails">Story Object</param> /// <returns>transaction results</returns> public TransactionResult UpdateStoryDetails(StoryObjects newStoryDetails) { var result = new TransactionResult(); try { newStoryDetails.ThemeId = GetThemeId(newStoryDetails.ThemeName, newStoryDetails.ProjectId, newStoryDetails.CreatedBy).Id; newStoryDetails.PriorityId = GetPriorityId(newStoryDetails.Priority, newStoryDetails.CreatedBy).Id; newStoryDetails.EpicId = GetEpicId(newStoryDetails.EpicName, newStoryDetails.ProjectId, newStoryDetails.CreatedBy).Id; using (var context = new TaskPlannerEntities()) { if (newStoryDetails != null && newStoryDetails.StoryId > 0) { var storyDetailsObj = (from story in context.Stories.Where(i => i.StoryId == newStoryDetails.StoryId && i.IsActive) select story).FirstOrDefault(); if (storyDetailsObj != null) { storyDetailsObj.TaskId = newStoryDetails.TaskId; storyDetailsObj.Title = newStoryDetails.Title; storyDetailsObj.Description = newStoryDetails.Description; storyDetailsObj.ProjectId = newStoryDetails.ProjectId; storyDetailsObj.ThemeId = newStoryDetails.ThemeId; storyDetailsObj.EpicId = newStoryDetails.EpicId; storyDetailsObj.PriorityId = newStoryDetails.PriorityId; storyDetailsObj.Milestone = newStoryDetails.Milestone; storyDetailsObj.Release = newStoryDetails.Release; storyDetailsObj.Status = newStoryDetails.Status; storyDetailsObj.StoryPoints = newStoryDetails.StoryPoints; storyDetailsObj.Benefit = newStoryDetails.Benifit; storyDetailsObj.Penality = newStoryDetails.Penalty; storyDetailsObj.SortOrder = newStoryDetails.SortOrder; storyDetailsObj.AssigneeName = newStoryDetails.AssigneeName; storyDetailsObj.SprintName = newStoryDetails.SprintName; storyDetailsObj.CreatedOn = newStoryDetails.CreatedOn; storyDetailsObj.UpdatedOn = DateTime.Now; storyDetailsObj.Tag = newStoryDetails.Tag; result.IsNewRecord = false; } } else { var newStory = new Story() { TaskId = newStoryDetails.TaskId, Title = newStoryDetails.Title, Description = newStoryDetails.Description, ProjectId = newStoryDetails.ProjectId, ThemeId = newStoryDetails.ThemeId, EpicId = newStoryDetails.EpicId, PriorityId = newStoryDetails.PriorityId, Milestone = newStoryDetails.Milestone, Release = newStoryDetails.Release, Status = newStoryDetails.Status, StoryPoints = newStoryDetails.StoryPoints, Benefit = newStoryDetails.Benifit, Penality = newStoryDetails.Penalty, SortOrder = newStoryDetails.SortOrder, CreatedBy = newStoryDetails.CreatedBy, AssigneeName = newStoryDetails.AssigneeName, SprintName = newStoryDetails.SprintName, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now, Tag = newStoryDetails.Tag, IsActive = true }; context.Stories.Add(newStory); result.IsNewRecord = true; } context.SaveChanges(); } result.IsSuccess = true; } catch (Exception ex) { result.IsSuccess = false; result.Exception = ex; } return(result); }
public IActionResult FinishVoting(int roomId, int storyId, int currentStoryIndex, string filter) { UserList user = GetCurrentUser(new UserList().DefaultUserId); int currentUserId = user.UserId; bool? isOwner = IsRoomOwner(currentUserId, roomId); var settings = new JsonSerializerSettings(); var result = new StoryObjects(); if (isOwner != null) { if (isOwner.Value) { result = new Rooms(iHttpContextAccessor, isignalRhub).FinishVoting(roomId, storyId); if (result != null && result.IsSuccess) { this.isignalRhub.RefreshPage(roomId, currentUserId, ValidationMessages.EstimationCompletedMessage); result.IsOwner = true; } else { if (result != null && !result.IsSuccess && result.Message == "already estimated") { result.ErrorMessage = ValidationMessages.AlreadyEstimatedMessage; } else { result = new StoryObjects(); result.ErrorMessage = ValidationMessages.ErrorMessage; } } if (result != null) { ViewBag.StoryStartTime = result.StartTime; ViewBag.StoryEndTime = result.EndTime; ViewBag.StoryIdleTime = result.IdleTime; ViewBag.StoryTotalTime = result.TotalTime; } } else { result = new StoryObjects(); result.IsOwner = false; result.ErrorMessage = ValidationMessages.AccessDeniedMessage; } } else { result = new StoryObjects(); result.ErrorMessage = ValidationMessages.ErrorMessage; } ViewBag.HasTimer = true; ViewBag.StoryId = currentStoryIndex; var storydetails = new Rooms(iHttpContextAccessor, isignalRhub).GetStoryList(roomId, string.Empty, filter); ViewBag.TotalStories = storydetails.Count; bool checkPendingStory = false; for (int i = 0; i < storydetails.Count; i++) { if (storydetails[i].StoryId < storyId) { if (!storydetails[i].IsEstimated) { checkPendingStory = true; break; } } } ViewBag.CheckPendingStory = checkPendingStory; return(this.PartialView("~/Views/Home/_TeamAverage.cshtml", result)); }
/// <summary> /// Method to add/update story /// </summary> /// <param name="storyObj">Story Objects/param> /// <returns>transaction results</returns> public TransactionResult AddUpdateStory(StoryObjects storyObj) { var result = this.iStoryBase.UpdateStoryDetails(storyObj); return(result); }