prasadnarwadkar_ASPNETCorePostgreSQL/ASPNETIdentityPostgres/Areas/ADT/Views/Patients/ActivitiCompleteSimpleTask.cshtml
@model ASPNETIdentityPostgres.Areas.ADT.Models.AlfrescoTaskCompletionVars

@{
    

    ViewData["Title"] = "Complete User Message Task";

    var username = User.Identity.Name;

    var employeeBeingEvaluated = Model.variables.FirstOrDefault(v => v.name == "employee").value;

    var bpmRole = "";

    var mapping = ASPNETIdentityPostgres.Areas.ADT.Models.WebAppAndBPMUserMap.mappings.FirstOrDefault(m => m.UserNameOnWebApp.ToLower() == username.ToLower());

    if (mapping != null)
    {
        bpmRole = mapping.UserRoleOnActivitiEngineOrApp;
    }

    var employeeUsernames = ASPNETIdentityPostgres.Areas.ADT.Models.WebAppAndBPMUserMap.mappings.Where(m => m.UserIdOnActivitiEngineOrApp.ToLower() == username.ToLower());
    var hrUsername = ASPNETIdentityPostgres.Areas.ADT.Models.WebAppAndBPMUserMap.mappings.FirstOrDefault(m => m.UserRoleOnActivitiEngineOrApp.ToLower() == "hr_admin")?.UserNameOnWebApp;
    var pmUsername = ASPNETIdentityPostgres.Areas.ADT.Models.WebAppAndBPMUserMap.mappings.FirstOrDefault(m => m.UserRoleOnActivitiEngineOrApp.ToLower() == "pm")?.UserNameOnWebApp;
}

<h3>Complete Task: @Model.taskname (Alfresco Activiti)</h3>

<div>
    <div class="row">
        <div class="col-md-6">
            @if (bpmRole == "pm")
            {
                <p>You are a Project Manager.</p>
            }

            @if (bpmRole == "hr_admin")
            {
                <p>You are an HR/administrator.</p>
            }

            @if (bpmRole == "employee")
            {
                <p>You are an employee.</p>
            }
        <form asp-action="ActivitiCompleteSimpleTask">
            @Html.HiddenFor(model => model.taskid)
            @Html.HiddenFor(model => model.taskname)
            @Html.HiddenFor(model => model.action)
            @Html.HiddenFor(model => model.processInstanceId)

            <div asp-validation-summary="All" class="text-danger"></div>
           
            <table class="table">
                
                <tbody>

                    <tr>
                        <td>
                            <span class="glyphicon glyphicon-user"></span> Employee
                        </td>

                        <td>
                            @Model.employee
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="glyphicon glyphicon-comment"></span> By Self
                        </td>

                        <td>
                            @Model.self
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <span class="glyphicon glyphicon-comment"></span> By HR
                        </td>

                        <td>
                            @Model.hr
                        </td>
                    </tr>

                    <tr>
                        <td>
                            <span class="glyphicon glyphicon-comment"></span> By PM
                        </td>

                        <td>
                            @Model.pm
                        </td>
                    </tr>

                </tbody>
            </table>

            @if (Model.taskname == "Self Evaluation")
            {
                if (bpmRole == "employee" && username.ToLower() == employeeBeingEvaluated.ToLower())
                {
                    @Html.HiddenFor(model => model.employee)
                    @Html.HiddenFor(model => model.hr)
                    @Html.HiddenFor(model => model.pm)

                    <div class="form-group">
                        <label asp-for="self" class="control-label"><span class="glyphicon glyphicon-comment"></span> Self Evaluation</label>
                        <input asp-for="self" class="form-control" />
                        <span asp-validation-for="self" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <input type="submit" value="Submit" class="btn btn-primary" />
                    </div>
                }
                else
                {
                    <p class="alert-danger">Please login as @employeeBeingEvaluated to evaluate yourself as an employee.</p>
                }
            }

            @if (Model.taskname == "PM Evaluation")
            {
                if (bpmRole == "pm")
                {
                    @Html.HiddenFor(model => model.employee)
                    @Html.HiddenFor(model => model.hr)
                    @Html.HiddenFor(model => model.self)

                    <div class="form-group">
                        <label asp-for="pm" class="control-label"><span class="glyphicon glyphicon-comment"></span> PM Evaluation</label>
                        <input asp-for="pm" class="form-control" />
                        <span asp-validation-for="pm" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <input type="submit" value="Submit" class="btn btn-primary" />
                    </div>
                }
                else
                {
                    <p class="alert-danger">Please login as @pmUsername to evaluate an employee as a PM.</p>
                }
            }

            @if (Model.taskname == "HR Evaluation")
            {
                if (bpmRole == "hr_admin")
                {
                    @Html.HiddenFor(model => model.employee)
                    @Html.HiddenFor(model => model.pm)
                    @Html.HiddenFor(model => model.self)

                    <div class="form-group">
                        <label asp-for="hr" class="control-label"><span class="glyphicon glyphicon-comment"></span> HR Evaluation</label>
                        <input asp-for="hr" class="form-control" />
                        <span asp-validation-for="hr" class="text-danger"></span>
                    </div>

                    <div class="form-group">
                        <input type="submit" value="Submit" class="btn btn-primary" />
                    </div>
                }
                else
                {
                    <p class="alert-danger">Please login as @hrUsername to evaluate an employee as an HR.</p>
                }
            }


            <div class="form-group">
                <a asp-action="MySimpleProcesses" class="btn btn-danger" title="I do not have Alfresco Activiti running on my machine.">Cancel</a>
            </div>
        </form>
        </div>
        <div class="col-md-6">
            <img src="@Url.Action("DownloadDiagram", "Patients", new { id = Model.processInstanceId })" class="hide"/>
        </div>
    </div>
</div>

