Example #1
0
    public async Task <IActionResult> OnPostDeleteTemplateVersion()
    {
        // TODO: Error handling
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(DeleteTemplateVersion.VersionId) &&
                                                                    x.TemplateId.Equals(DeleteTemplateVersion.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(DeleteTemplateVersion.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException();
        }

        await _templateVersionTbl.Delete(DeleteTemplateVersion.VersionId);

        await _templateTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.TemplateId), _ => new TemplateTbl
        {
            DateModified = DateTime.Now
        });

        await _projectTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.ProjectId), _ => new ProjectTbl
        {
            DateModified = DateTime.Now
        });

        TempData["toastStatus"]  = "success";
        TempData["toastMessage"] = "Template version deleted";
        TempData["scrollToId"]   = $"template-{DeleteTemplateVersion.TemplateId}";

        return(RedirectToPage("/Project/Details", new { id = DeleteTemplateVersion.ProjectId }));
    }
Example #2
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            // Put user code to initialize the page here
            if (Page.IsPostBack)
            {
                return;
            }

            try
            {
                IList <string> segments = Request.GetFriendlyUrlSegments();
                ProjectId = Int32.Parse(segments[0]);
            }
            catch
            {
                ProjectId = Request.QueryString.Get("pid", 0);
            }

            // BGN-1379
            if (ProjectId.Equals(0))
            {
                ErrorRedirector.TransferToNotFoundPage(Page);
            }

            BindProjectSummary();

            // SiteMap.SiteMapResolve += ExpandPaths;
        }
Example #3
0
 public bool Equals(ProjectContract other)
 {
     if (other == null)
     {
         return(false);
     }
     return(ProjectId.Equals(other.ProjectId) &&
            ContractType.Equals(other.ContractType)
            );
 }
Example #4
0
 public override bool Equals(object obj)
 {
     var projectMember = obj as ProjectMember;
     if (projectMember != null)
     {
         return ProjectId.Equals(projectMember.ProjectId) &&
                EmployeeId.Equals(projectMember.EmployeeId);
     }
     return false;
 }
Example #5
0
        public override bool Equals(object obj)
        {
            var timeEntry = obj as ProjectTime;

            if (timeEntry != null)
            {
                return(ProjectId.Equals(timeEntry.ProjectId) &&
                       EmployeeId.Equals(timeEntry.EmployeeId) &&
                       Date.CompareDate(timeEntry.Date));
            }
            return(false);
        }
Example #6
0
 public bool Equals(ProjectLogsDto other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(AssigneeId.Equals(other.AssigneeId) && ProjectId.Equals(other.ProjectId) &&
            ProjectGroupId.Equals(other.ProjectGroupId) && LoggedTimeId.Equals(other.LoggedTimeId));
 }
        /// <inheritdoc />
        public bool Equals(ProjectBindingModel other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }

            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                (ProjectId.Equals(other.ProjectId) &&
                 string.Equals(MaskProjectVersion, other.MaskProjectVersion, StringComparison.OrdinalIgnoreCase));
        }
Example #8
0
    public async Task <IActionResult> OnPostMarkAsActive()
    {
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(MarkAsActive.VersionId) &&
                                                                    x.TemplateId.Equals(MarkAsActive.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(MarkAsActive.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException(nameof(version));
        }

        version.IsActive = true;

        _templateVersionTbl.Update(version);

        await _templateVersionTbl.UpdateFromQuery(x =>
                                                  x.IsActive &&
                                                  !x.Id.Equals(version.Id) &&
                                                  x.TemplateId.Equals(version.TemplateId),
                                                  _ =>
                                                  new TemplateVersionTbl
        {
            IsActive = false
        });

        await _templateTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.TemplateId), _ => new TemplateTbl
        {
            DateModified = DateTime.Now
        });

        await _projectTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.ProjectId), _ => new ProjectTbl
        {
            DateModified = DateTime.Now
        });

        TempData["toastStatus"]  = "success";
        TempData["toastMessage"] = "Template version marked as active";
        TempData["scrollToId"]   = $"version-{version.Id}";

        return(RedirectToPage("/Project/Details", new { id = MarkAsActive.ProjectId }));
    }
        public bool Equals(XunitTestTheoryTask other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            // Do not include base.Equals, so we don't try to compare Id or ParentId,
            // which will be different for each instance, and we're trying to act like
            // a value type
            return(ProjectId.Equals(other.ProjectId) &&
                   TypeName.Equals(other.TypeName) &&
                   MethodName.Equals(other.MethodName) &&
                   TheoryName.Equals(other.TheoryName));
        }
Example #10
0
 public bool Equals(ProjectLoggsDto other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(ProjectName == other.ProjectName &&
            AssigneeName == other.AssigneeName &&
            ActivityName == other.ActivityName &&
            ActivityStatus == other.ActivityStatus &&
            ActivityType == other.ActivityType &&
            EstimatedTime.Equals(other.EstimatedTime) &&
            LoggedTime.Equals(other.LoggedTime) &&
            ProjectId.Equals(other.ProjectId) &&
            ActivityId.Equals(other.ActivityId) &&
            AssigneeId.Equals(other.AssigneeId));
 }
Example #11
0
    public async Task <IActionResult> OnPostDuplicateTemplateVersion()
    {
        // TODO: Error handling
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(DuplicateTemplateVersion.VersionId) &&
                                                                    x.TemplateId.Equals(DuplicateTemplateVersion.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(DuplicateTemplateVersion.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException(nameof(version));
        }

        TemplateVersionTbl result = await _templateVersionTbl.Add(new TemplateVersionTbl
        {
            Name       = $"{version.Name}_copy",
            Subject    = version.Subject,
            TestData   = version.TestData,
            Html       = version.Html,
            Categories = version.Categories,
            TemplateId = version.TemplateId
        });

        await _templateTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.TemplateId), _ => new TemplateTbl
        {
            DateModified = DateTime.Now
        });

        await _projectTbl.UpdateFromQuery(x => x.Id.Equals(MarkAsActive.ProjectId), _ => new ProjectTbl
        {
            DateModified = DateTime.Now
        });

        TempData["toastStatus"]  = "success";
        TempData["toastMessage"] = "Template version duplicated";
        TempData["scrollToId"]   = $"version-{result.Id}";

        return(RedirectToPage("/Project/Details", new { id = DuplicateTemplateVersion.ProjectId }));
    }
Example #12
0
    public async Task <IActionResult> OnPostUpdateSettings()
    {
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(UpdateSettings.VersionId) &&
                                                                    x.TemplateId.Equals(UpdateSettings.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(UpdateSettings.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException();
        }

        version.Name    = UpdateSettings.Name;
        version.Subject = UpdateSettings.Subject;

        _templateVersionTbl.Update(version);

        await _templateTbl.UpdateFromQuery(x => x.Id.Equals(UpdateSettings.TemplateId), _ => new TemplateTbl
        {
            DateModified = DateTime.Now
        });

        await _projectTbl.UpdateFromQuery(x => x.Id.Equals(UpdateSettings.ProjectId), _ => new ProjectTbl
        {
            DateModified = DateTime.Now
        });

        TempData["toastStatus"]  = "success";
        TempData["toastMessage"] = "Template updated";

        return(RedirectToPage("/Project/Template", new
        {
            projectId = UpdateTemplate.ProjectId,
            templateId = UpdateTemplate.TemplateId,
            versionId = UpdateTemplate.VersionId
        }));
    }
Example #13
0
 public bool Equals(DependentProject other)
 {
     return(HasInternalsAccess == other.HasInternalsAccess && ProjectId.Equals(other.ProjectId));
 }
Example #14
0
    public async Task <IActionResult> OnPostTestSend()
    {
        // Get template
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(UpdateSettings.VersionId) &&
                                                                    x.TemplateId.Equals(UpdateSettings.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(UpdateSettings.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException();
        }

        // Generate body
        Handlebars.RegisterHelper("ifCond", (output, options, context, arguments) =>
        {
            if (arguments.Length != 3)
            {
                throw new HandlebarsException("{{#StringEqualityBlockHelper}} helper must have exactly 3 arguments");
            }

            string v1        = arguments.At <string>(0);
            string @operator = arguments.At <string>(1);
            string v2        = arguments.At <string>(0);

            switch (@operator)
            {
            case "==":
                if (v1 == v2)
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;

            case "!=":
                if (v1 != v2)
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;

            case "<":
                if (Convert.ToDouble(v1) < Convert.ToDouble(v2))
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;

            case "<=":
                if (Convert.ToDouble(v1) <= Convert.ToDouble(v2))
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;

            case ">":
                if (Convert.ToDouble(v1) > Convert.ToDouble(v2))
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;

            case ">=":
                if (Convert.ToDouble(v1) >= Convert.ToDouble(v2))
                {
                    options.Template(output, context);
                }
                else
                {
                    options.Inverse(output, context);
                }
                break;
            }
        });
        HandlebarsTemplate <object, object> subjectTemplate = Handlebars.Compile(version.Subject);
        string subjectResult = subjectTemplate(JObject.Parse(version.TestData !));

        HandlebarsTemplate <object, object> bodyTemplate = Handlebars.Compile(version.Html);
        string bodyResult = bodyTemplate(JObject.Parse(version.TestData !));

        await _emailService.SendEmail(new List <MailboxAddress> {
            new MailboxAddress(TestSend.Name, TestSend.Email)
        }, subjectResult, bodyResult, version.TestData !);

        return(RedirectToPage("/Project/Template", new
        {
            projectId = TestSend.ProjectId,
            templateId = TestSend.TemplateId,
            versionId = TestSend.VersionId
        }));
    }
Example #15
0
 public bool Equals(SerializableSymbolAndProjectId other)
 => other != null && SymbolKeyData.Equals(other.SymbolKeyData) && ProjectId.Equals(other.ProjectId);
Example #16
0
    public async Task <IActionResult> OnPostUpdateTemplate()
    {
        UpdateTemplate.Html     = string.IsNullOrWhiteSpace(UpdateTemplate.Html) ? string.Empty : UpdateTemplate.Html;
        UpdateTemplate.TestData = string.IsNullOrWhiteSpace(UpdateTemplate.TestData) ? "{}" : UpdateTemplate.TestData;
        try
        {
            Handlebars.RegisterHelper("ifCond", (output, options, context, arguments) =>
            {
                if (arguments.Length != 3)
                {
                    throw new HandlebarsException("{{#StringEqualityBlockHelper}} helper must have exactly two arguments");
                }

                string v1        = arguments.At <string>(0);
                string @operator = arguments.At <string>(1);
                string v2        = arguments.At <string>(0);

                switch (@operator)
                {
                case "==":
                    if (v1 == v2)
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;

                case "!=":
                    if (v1 != v2)
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;

                case "<":
                    if (Convert.ToDouble(v1) < Convert.ToDouble(v2))
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;

                case "<=":
                    if (Convert.ToDouble(v1) <= Convert.ToDouble(v2))
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;

                case ">":
                    if (Convert.ToDouble(v1) > Convert.ToDouble(v2))
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;

                case ">=":
                    if (Convert.ToDouble(v1) >= Convert.ToDouble(v2))
                    {
                        options.Template(output, context);
                    }
                    else
                    {
                        options.Inverse(output, context);
                    }
                    break;
                }
            });
            HandlebarsTemplate <object, object> template = Handlebars.Compile(UpdateTemplate.Html);
            template(JObject.Parse(UpdateTemplate.TestData));
        }
        catch (Exception)
        {
            TempData["toastStatus"]  = "error";
            TempData["toastMessage"] = "Parsing template failed. Please check ";

            return(RedirectToPage("/Project/Template", new
            {
                projectId = UpdateTemplate.ProjectId,
                templateId = UpdateTemplate.TemplateId,
                versionId = UpdateTemplate.VersionId
            }));
        }

        // TODO: Error handling
        TemplateVersionTbl?version = (await _templateVersionTbl.Get(x =>
                                                                    x.Id.Equals(UpdateTemplate.VersionId) &&
                                                                    x.TemplateId.Equals(UpdateTemplate.TemplateId) &&
                                                                    x.Template !.ProjectId.Equals(UpdateTemplate.ProjectId)))
                                     .FirstOrDefault();

        if (version == null)
        {
            throw new NullReferenceException();
        }

        version.TestData = UpdateTemplate.TestData;
        version.Html     = UpdateTemplate.Html;

        _templateVersionTbl.Update(version);

        await _templateTbl.UpdateFromQuery(x => x.Id.Equals(UpdateTemplate.TemplateId), _ => new TemplateTbl
        {
            DateModified = DateTime.Now
        });

        await _projectTbl.UpdateFromQuery(x => x.Id.Equals(UpdateTemplate.ProjectId), _ => new ProjectTbl
        {
            DateModified = DateTime.Now
        });

        // TODO: Generate thumbnail
        _jobClient.Enqueue(() => GenerateThumbnailAndPreview(version.Id));

        TempData["toastStatus"]  = "success";
        TempData["toastMessage"] = "Template updated";

        return(RedirectToPage("/Project/Template", new
        {
            projectId = UpdateTemplate.ProjectId,
            templateId = UpdateTemplate.TemplateId,
            versionId = UpdateTemplate.VersionId
        }));
    }
        /// <summary>
        /// Returns true if RentalRequestSearchResultViewModel instances are equal
        /// </summary>
        /// <param name="other">Instance of RentalRequestSearchResultViewModel to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(RentalRequestSearchResultViewModel other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id.Equals(other.Id)
                     ) &&
                 (
                     LocalArea == other.LocalArea ||
                     LocalArea != null &&
                     LocalArea.Equals(other.LocalArea)
                 ) &&
                 (
                     EquipmentCount == other.EquipmentCount ||
                     EquipmentCount != null &&
                     EquipmentCount.Equals(other.EquipmentCount)
                 ) &&
                 (
                     EquipmentTypeName == other.EquipmentTypeName ||
                     EquipmentTypeName != null &&
                     EquipmentTypeName.Equals(other.EquipmentTypeName)
                 ) &&
                 (
                     ProjectName == other.ProjectName ||
                     ProjectName != null &&
                     ProjectName.Equals(other.ProjectName)
                 ) &&
                 (
                     PrimaryContact == other.PrimaryContact ||
                     PrimaryContact != null &&
                     PrimaryContact.Equals(other.PrimaryContact)
                 ) &&
                 (
                     Status == other.Status ||
                     Status != null &&
                     Status.Equals(other.Status)
                 ) &&
                 (
                     ProjectId == other.ProjectId ||
                     ProjectId != null &&
                     ProjectId.Equals(other.ProjectId)
                 ) &&
                 (
                     ExpectedStartDate == other.ExpectedStartDate ||
                     ExpectedStartDate != null &&
                     ExpectedStartDate.Equals(other.ExpectedStartDate)
                 ) &&
                 (
                     ExpectedEndDate == other.ExpectedEndDate ||
                     ExpectedEndDate != null &&
                     ExpectedEndDate.Equals(other.ExpectedEndDate)
                 ));
        }
Example #18
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Page.IsPostBack)
            {
                return;
            }

            ctlDisplayIssues.PageSize         = UserManager.GetProfilePageSize();
            ctlDisplayIssues.CurrentPageIndex = 0;

            ProjectId = Request.Get("pid", -1);

            // BGN-1379
            if (ProjectId.Equals(-1))
            {
                ErrorRedirector.TransferToNotFoundPage(Page);
            }

            if (!User.Identity.IsAuthenticated)
            {
                dropView.Items.Remove(dropView.Items.FindByValue("Relevant"));
                dropView.Items.Remove(dropView.Items.FindByValue("Assigned"));
                dropView.Items.Remove(dropView.Items.FindByValue("Owned"));
                dropView.Items.Remove(dropView.Items.FindByValue("Created"));
                dropView.SelectedIndex = 1;
            }

            var state = (IssueListState)Session[ISSUELISTSTATE];

            if (state != null)
            {
                if (Request.QueryString.Count == 1 && state.ViewIssues == string.Empty)
                {
                    state.ViewIssues = "Open";
                }

                if ((ProjectId > 0) && (ProjectId != state.ProjectId))
                {
                    Session.Remove(ISSUELISTSTATE);
                }
                else
                {
                    if (Request.QueryString.Count > 1)
                    {
                        state.ViewIssues = string.Empty;
                    }

                    dropView.SelectedValue = state.ViewIssues;
                    ProjectId = state.ProjectId;
                    ctlDisplayIssues.CurrentPageIndex = state.IssueListPageIndex;
                    ctlDisplayIssues.SortField        = state.SortField;
                    ctlDisplayIssues.SortAscending    = state.SortAscending;
                    ctlDisplayIssues.PageSize         = state.PageSize;
                }
            }
            else
            {
                if (Request.QueryString.Count > 1)
                {
                    dropView.SelectedValue = string.Empty;
                }
            }

            BindIssues();
        }