public ViewResult Detail(PerformanceMeasurePrimaryKey performanceMeasurePrimaryKey)
        {
            var performanceMeasure          = performanceMeasurePrimaryKey.EntityObject;
            var canManagePerformanceMeasure = new PerformanceMeasureManageFeature().HasPermissionByFirmaSession(CurrentFirmaSession);
            var isAdmin = new FirmaAdminFeature().HasPermissionByFirmaSession(CurrentFirmaSession);

            var performanceMeasureChartViewData = new PerformanceMeasureChartViewData(performanceMeasure,
                                                                                      CurrentFirmaSession, false, canManagePerformanceMeasure,
                                                                                      performanceMeasure.GetAssociatedProjectsWithReportedValues(CurrentFirmaSession));

            // Avoid scrolling the legend if it can be displayed on two lines
            performanceMeasureChartViewData.ViewGoogleChartViewData.GoogleChartJsons.ForEach(x =>
            {
                if (x.GoogleChartConfiguration.Legend != null && x.GoogleChartConfiguration.Legend.MaxLines == null)
                {
                    x.GoogleChartConfiguration.Legend.MaxLines = 2;
                }
            });

            var entityNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(performanceMeasure.PerformanceMeasureNotes),
                SitkaRoute <PerformanceMeasureNoteController> .BuildUrlFromExpression(c =>
                                                                                      c.New(performanceMeasure.PrimaryKey)),
                performanceMeasure.PerformanceMeasureDisplayName,
                canManagePerformanceMeasure);

            var viewData = new DetailViewData(CurrentFirmaSession, performanceMeasure, performanceMeasureChartViewData,
                                              entityNotesViewData, canManagePerformanceMeasure, isAdmin);

            return(RazorView <Detail, DetailViewData>(viewData));
        }
예제 #2
0
        public ViewResult GrantAllocationDetail(GrantAllocationPrimaryKey grantAllocationPrimaryKey)
        {
            var grantAllocation = grantAllocationPrimaryKey.EntityObject;

            if (grantAllocation == null)
            {
                throw new Exception($"Could not find GrantAllocationID # {grantAllocationPrimaryKey.PrimaryKeyValue}; has it been deleted?");
            }

            var taxonomyLevel = MultiTenantHelpers.GetTaxonomyLevel();
            var grantAllocationBasicsViewData         = new GrantAllocationBasicsViewData(grantAllocation, false, taxonomyLevel);
            var userHasEditGrantAllocationPermissions = new GrantAllocationEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);
            var grantAllocationNotesViewData          = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNotes)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNote(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);
            var grantAllocationNoteInternalsViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantAllocation.GrantAllocationNoteInternals)),
                SitkaRoute <GrantAllocationController> .BuildUrlFromExpression(x => x.NewGrantAllocationNoteInternal(grantAllocationPrimaryKey)),
                grantAllocation.GrantAllocationName,
                userHasEditGrantAllocationPermissions);

            var costTypes = CostType.All.Where(x => x.IsValidInvoiceLineItemCostType).OrderBy(x => x.CostTypeDisplayName).ToList();

            const string chartTitle       = "Grant Allocation Expenditures";
            var          chartContainerID = chartTitle.Replace(" ", "");

            // If ProjectGrantAllocationExpenditures is empty, ToGoogleChart returns null...
            var googleChart = grantAllocation.GrantAllocationExpenditures
                              .ToGoogleChart(x => x.CostType?.CostTypeDisplayName,
                                             costTypes.Select(x => x.CostTypeDisplayName).ToList(),
                                             x => x.CostType?.CostTypeDisplayName,
                                             chartContainerID,
                                             grantAllocation.DisplayName);

            // Which makes this guy bork (bork bork bork)
            googleChart?.GoogleChartConfiguration.Legend.SetLegendPosition(GoogleChartLegendPosition.Top);
            var viewGoogleChartViewData = new ViewGoogleChartViewData(googleChart, chartTitle, 350, false);

            var projectGrantAllocationRequestsGridSpec = new ProjectGrantAllocationRequestsGridSpec()
            {
                ObjectNameSingular  = "Project",
                ObjectNamePlural    = "Projects",
                SaveFiltersInCookie = true
            };

            var grantAllocationExpendituresGridSpec = new GrantAllocationExpendituresGridSpec();
            var grantAllocationAwardsGridSpec       = new GrantAllocationAwardGridSpec(CurrentPerson, grantAllocation);

            var viewData = new Views.GrantAllocation.DetailViewData(CurrentPerson, grantAllocation, grantAllocationBasicsViewData, grantAllocationNotesViewData, grantAllocationNoteInternalsViewData, viewGoogleChartViewData, projectGrantAllocationRequestsGridSpec, grantAllocationExpendituresGridSpec, grantAllocationAwardsGridSpec);

            return(RazorView <Views.GrantAllocation.Detail, Views.GrantAllocation.DetailViewData>(viewData));
        }
예제 #3
0
        public IHttpActionResult InsertNotedata(VMNoteModel entity)
        {
            var repository = new RepositoryNote();
            var response   = new DataResponse <EntityNote>();

            if (ModelState.IsValid)
            {
                string typeValue = ControllerContext.RouteData.Values["Type"].ToString();
                entity.ParentId = int.Parse(ControllerContext.RouteData.Values["ParentId"].ToString());

                switch (typeValue)
                {
                case "tasks":
                    entity.ParentTypeId = (int)NoteType.Task;
                    break;

                case "leads":
                case "accounts":
                    entity.ParentTypeId = (int)NoteType.Lead;
                    break;
                }

                var model = new EntityNote
                {
                    Id            = entity.Id,
                    ParentId      = entity.ParentId,
                    ParentTypeId  = entity.ParentTypeId,
                    CreatedBy     = CurrentUser.Id,
                    UpdatedBy     = CurrentUser.Id,
                    Description   = entity.Description,
                    CreatedOn     = DateTime.UtcNow,
                    BusinessId    = CurrentBusinessId,
                    CreatedByName = string.Format("{0} {1}", CurrentUser.FirstName, CurrentUser.LastName)
                };

                response = repository.SaveNote(model);
            }
            else
            {
                var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new
                {
                    Key     = s.Key.Split('.').Last(),
                    Message = s.Value.Errors[0].ErrorMessage
                });
                return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList }));
            }
            var dataResponse = repository.GetNoteById(response.Model.ParentId, response.Model.ParentTypeId);

            // response.Message = response.Model.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss:fff");
            //response.Model.CreatedOn = DateTime.Parse(response.Model.CreatedOn.ToString("yyyy-MM-dd HH:mm:ss:fff"));
            return(Ok <DataResponse>(dataResponse));
        }
        public DocumentsAndNotesViewData(Person currentPerson, ProjectUpdateBatch projectUpdateBatch, UpdateStatus updateStatus, string diffUrl) : base(currentPerson, projectUpdateBatch, updateStatus, new List <string>(), ProjectUpdateSection.NotesAndDocuments.ProjectUpdateSectionDisplayName)
        {
            EntityNotesViewData = new EntityNotesViewData(EntityNote.CreateFromEntityNote(new List <IEntityNote>(projectUpdateBatch.ProjectNoteUpdates)),
                                                          SitkaRoute <ProjectNoteUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                          projectUpdateBatch.Project.DisplayName,
                                                          IsEditable);
            ProjectDocumentsViewData = new ProjectDocumentsDetailViewData(EntityDocument.CreateFromEntityDocument(new List <IEntityDocument>(projectUpdateBatch.ProjectDocumentUpdates)),
                                                                          SitkaRoute <ProjectDocumentUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                                          projectUpdateBatch.Project.DisplayName,
                                                                          IsEditable);
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshNotesAndDocuments(projectUpdateBatch.Project));

            DiffUrl = diffUrl;
        }
        public ViewResult GrantModificationDetail(GrantModificationPrimaryKey grantModificationPrimaryKey)
        {
            var grantModification = grantModificationPrimaryKey.EntityObject;
            var userHasEditGrantModificationPermissions = new GrantModificationEditAsAdminFeature().HasPermissionByPerson(CurrentPerson);


            var internalGrantModificationNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(new List <IEntityNote>(grantModification.GrantModificationNoteInternals)),
                SitkaRoute <GrantModificationController> .BuildUrlFromExpression(x => x.NewGrantModificationNoteInternal(grantModificationPrimaryKey)),
                grantModification.GrantModificationName,
                userHasEditGrantModificationPermissions);

            var viewData = new GrantModificationDetailViewData(CurrentPerson, grantModification, internalGrantModificationNotesViewData);

            return(RazorView <GrantModificationDetail, GrantModificationDetailViewData>(viewData));
        }
        public ViewResult ObligationRequestDetail(ObligationRequestPrimaryKey obligationRequestPrimaryKey)
        {
            var obligationRequest = obligationRequestPrimaryKey.EntityObject;

            var userCanInteractWithSubmissionNotes = new ObligationRequestSubmissionNoteFeature().HasPermissionByFirmaSession(CurrentFirmaSession);

            var obligationRequestNotesViewData = new EntityNotesViewData(
                EntityNote.CreateFromEntityNote(obligationRequest.ObligationRequestSubmissionNotes),
                SitkaRoute <ObligationRequestSubmissionNotesController> .BuildUrlFromExpression(x => x.New(obligationRequest)),
                FieldDefinitionEnum.ObligationRequest.ToType().FieldDefinitionDisplayName,
                userCanInteractWithSubmissionNotes);

            var viewData = new ObligationRequestDetailViewData(CurrentFirmaSession, obligationRequest, userCanInteractWithSubmissionNotes, obligationRequestNotesViewData);

            return(RazorView <ObligationRequestDetail, ObligationRequestDetailViewData>(viewData));
        }
예제 #7
0
        public DataResponse <EntityNote> GetNoteById(int ParentId, int ParentTypeId)
        {
            DataResponse <EntityNote> response = new DataResponse <EntityNote>();

            try
            {
                base.DBInit();



                base.DBInit();

                var query  = DBEntity.Notes.Where(a => a.ParentTypeId == ParentTypeId & a.ParentId == ParentId).OrderByDescending(a => a.Id).FirstOrDefault();
                var entity = new EntityNote
                {
                    Id           = query.Id,
                    ParentId     = query.ParentId,
                    ParentTypeId = query.ParentTypeId,
                    Description  = query.Description,
                    CreatedBy    = query.CreatedBy,
                    CreatedOn    = query.CreatedOn,
                    UserDetails  = new UserDetails {
                        UserId = query.CreatedBy, Name = query.User.FirstName + " " + query.User.LastName, date = query.CreatedOn.ToString()
                    }
                };

                if (query != null)
                {
                    response.CreateResponse(entity, DataResponseStatus.OK);
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                response.ThrowError(ex);
            }

            finally
            {
                base.DBClose();
            }
            return(response);
        }
        public AttachmentsAndNotesViewData(FirmaSession currentFirmaSession, ProjectUpdateBatch projectUpdateBatch, ProjectUpdateStatus projectUpdateStatus, string diffUrl) : base(currentFirmaSession, projectUpdateBatch, projectUpdateStatus, new List <string>(), ProjectUpdateSection.AttachmentsAndNotes.ProjectUpdateSectionDisplayName)
        {
            EntityNotesViewData = new EntityNotesViewData(EntityNote.CreateFromEntityNote(projectUpdateBatch.ProjectNoteUpdates),
                                                          SitkaRoute <ProjectNoteUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                                                          projectUpdateBatch.Project.GetDisplayName(),
                                                          IsEditable);
            ProjectAttachmentsViewData = new ProjectAttachmentsDetailViewData(
                EntityAttachment.CreateFromProjectAttachment(projectUpdateBatch.ProjectAttachmentUpdates),
                SitkaRoute <ProjectAttachmentUpdateController> .BuildUrlFromExpression(x => x.New(projectUpdateBatch)),
                projectUpdateBatch.Project.GetDisplayName(),
                IsEditable,
                projectUpdateBatch.GetAllAttachmentTypes().ToList(),
                currentFirmaSession);
            RefreshUrl = SitkaRoute <ProjectUpdateController> .BuildUrlFromExpression(x => x.RefreshNotesAndAttachments(projectUpdateBatch.Project));

            DiffUrl = diffUrl;

            var applicableWizardSections = projectUpdateBatch.GetApplicableWizardSections(currentFirmaSession, true, projectUpdateBatch.Project.HasEditableCustomAttributes(CurrentFirmaSession));
            var currentSection           = applicableWizardSections.Single(x => x.SectionDisplayName.Equals(ProjectUpdateSection.AttachmentsAndNotes.ProjectUpdateSectionDisplayName, StringComparison.InvariantCultureIgnoreCase));
            var nextProjectUpdateSection = applicableWizardSections.Where(x => x.SortOrder > currentSection.SortOrder).OrderBy(x => x.SortOrder).FirstOrDefault();

            NextSectionUrl = nextProjectUpdateSection?.SectionUrl;
        }
예제 #9
0
        public DataResponse <EntityNote> SaveNote(EntityNote entity)
        {
            DataResponse <EntityNote> response = new DataResponse <EntityNote>();

            try
            {
                base.DBInit();
                var model = new Database.Note
                {
                    Id           = entity.Id,
                    ParentId     = entity.ParentId,
                    ParentTypeId = entity.ParentTypeId,
                    Description  = entity.Description,
                    CreatedBy    = entity.CreatedBy,
                    CreatedOn    = DateTime.UtcNow,
                };

                int rowCount = entity.Id > 0 ? base.DBSaveUpdate(model) : base.DBSave(model);

                if (rowCount > 0)
                {
                    if (entity.ParentTypeId == (int)NoteType.Task)
                    {
                        var TaskModel = new RepositoryTask().GetTaskById(model.ParentId, entity.CreatedBy, entity.BusinessId);
                        if (TaskModel.Model != null)
                        {
                            //Add To Notification Table
                            List <EntityNotification> notificationlist = new List <EntityNotification>();

                            if (TaskModel.Model.AssignedTo > 0)
                            {
                                notificationlist.Add(new EntityNotification
                                {
                                    UserId  = TaskModel.Model.AssignedTo,
                                    Message = NotificationMessages.TaskNoteNotification
                                });
                            }

                            if (TaskModel.Model.Watchers != null)
                            {
                                foreach (var user in TaskModel.Model.Watchers)
                                {
                                    notificationlist.Add(new EntityNotification
                                    {
                                        UserId  = int.Parse(user),
                                        Message = NotificationMessages.TaskNoteNotification
                                    });
                                }
                            }

                            notificationlist.Add(new EntityNotification
                            {
                                UserId  = TaskModel.Model.CreatedBy,
                                Message = NotificationMessages.TaskNoteNotification
                            });

                            #region Save Notification Data

                            new RepositoryNotification().Save(notificationlist, entity.CreatedBy, model.Id, (int)NotificationTargetType.Task, (int)NotificationType.Normal, model.CreatedBy, entity.CreatedByName, model.CreatedOn, TaskModel.Model.Subject);

                            #endregion
                        }
                    }
                    entity.Id = model.Id;

                    entity.UserDetails = DBEntity.Users.Where(a => a.Id == model.CreatedBy).Select(a => new UserDetails {
                        UserId = model.CreatedBy, Name = a.FirstName + "" + a.LastName, date = model.CreatedOn.ToString()
                    }).FirstOrDefault();
                    response.CreateResponse(entity, DataResponseStatus.OK);
                }
                else
                {
                    response.CreateResponse(DataResponseStatus.InternalServerError);
                }
            }
            catch (Exception ex)
            {
                response.ThrowError(ex);
            }

            finally
            {
                base.DBClose();
            }
            return(response);
        }
        public IHttpActionResult InsertNotedata(VMNoteModel entity)
        {
            var repository = new RepositoryNote();
            var response   = new DataResponse();

            if (ModelState.IsValid)
            {
                string typeValue = ControllerContext.RouteData.Values["Type"].ToString();
                entity.ParentId = int.Parse(ControllerContext.RouteData.Values["ParentId"].ToString());

                switch (typeValue)
                {
                case "tasks":
                    entity.ParentTypeId = (int)NoteType.Task;
                    break;

                case "leads":
                    entity.ParentTypeId = (int)NoteType.Lead;
                    break;
                }

                var model = new EntityNote
                {
                    Id           = entity.Id,
                    ParentId     = entity.ParentId,
                    ParentTypeId = entity.ParentTypeId,
                    CreatedBy    = CurrentUser.Id,
                    UpdatedBy    = CurrentUser.Id,
                    Description  = entity.Description,
                };

                response = repository.SaveNote(model);
                if (entity.ParentTypeId == (int)NoteType.Task && response.Message == "OK")
                {
                    #region Send email to users in assigned to and watchers list
                    var CreatedByName = string.Format("{0} {1}", CurrentUser.FirstName, CurrentUser.LastName);
                    var TaskModel     = new RepositoryTask().GetTaskById(model.ParentId, CurrentUserId, CurrentBusinessId);
                    try
                    {
                        var    rootPath  = System.Web.Hosting.HostingEnvironment.ApplicationPhysicalPath;
                        var    ReturnUrl = ConfigurationManager.AppSettings["BaseUrl"] + CurrentUser.BusinessName.Replace(" ", "-") + "#/tasks/" + TaskModel.Model.ReferenceNumber;
                        var    Subject   = "Task " + TaskModel.Model.ReferenceNumber + " - " + TaskModel.Model.Subject + "";
                        var    mail      = new GMEmail();
                        string toEmails  = null;
                        if (CurrentUserId != TaskModel.Model.RequestedUser.UserId)
                        {
                            try
                            {
                                var emailBody = TemplateManager.NewNote(rootPath, TaskModel.Model.RequestedUser.Name, CreatedByName, TaskModel.Model.Subject, ReturnUrl, entity.Description, CurrentBusinessId.Value, CurrentUser.RelativeUrl);
                                mail.SendDynamicHTMLEmail(TaskModel.Model.RequestedUser.Email, Subject, emailBody, CurrentUser.OtherEmails);
                            }
                            catch (Exception ex)
                            {
                                ex.Log();
                            }
                        }
                        var UserList = TaskModel.Model.AssignedUsersList.Concat(TaskModel.Model.WatchersList);
                        foreach (var item in UserList)
                        {
                            if (item.UserId == CurrentUserId)
                            {
                                continue;
                            }

                            var emailBody = TemplateManager.NewNote(rootPath, item.Name, CreatedByName, TaskModel.Model.Subject, ReturnUrl, entity.Description, CurrentBusinessId.Value, CurrentUser.RelativeUrl);
                            try
                            {
                                toEmails = new RepositoryUserProfile().NotificationEnabledEmails(item.Email, "TSKNOTENFN");
                                if (!string.IsNullOrEmpty(toEmails))
                                {
                                    mail.SendDynamicHTMLEmail(item.Email, Subject, emailBody, CurrentUser.OtherEmails);
                                }
                            }
                            catch (Exception ex)
                            {
                                ex.Log();
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        ex.Log();
                    }

                    #endregion
                }
            }
            else
            {
                var errorList = ModelState.Where(a => a.Value.Errors.Any()).Select(s => new
                {
                    Key     = s.Key.Split('.').Last(),
                    Message = s.Value.Errors[0].ErrorMessage
                });
                return(Ok <dynamic>(new { Status = HttpStatusCode.BadRequest, Model = errorList }));
            }
            return(Ok <DataResponse>(response));
        }