prasadnarwadkar_ASPNETCorePostgreSQL/ASPNETIdentityPostgres/Areas/ADT/Views/Patients/ActivitiStartProcessInstance.cshtml
@model ASPNETIdentityPostgres.Areas.ADT.Models.AlfrescoActivitiProcessInstancePostData

@{
    ViewData["Title"] = "Start A New Process Instance";

    var employees = ASPNETIdentityPostgres.Areas.ADT.Models.BPMUsers.Users
        .Select(c => new SelectListItem() { Text = c.Key, Value = c.Value })
    .ToList();

    var username = User.Identity.Name;

    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.UserRoleOnActivitiEngineOrApp.ToLower() == "employee").Select(e => new SelectListItem { Text = e.UserIdOnActivitiEngineOrApp, Value = e.UserIdOnActivitiEngineOrApp }).ToList();
    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>Start a New Employee Evaluation</h3>

<div>

    <div class="row">
        <div class="col-md-12">
            @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="ActivitiStartProcessInstance">
                <div asp-validation-summary="All" class="text-danger"></div>
                <input type="hidden" asp-for="processDefinitionKey" value="@ASPNETIdentityPostgres.Areas.ADT.Models.Constants.ActivitiProcessDefId" />

                <div class="row">
                    <div class="col-md-4">
                        <label class="control-label">Select Employee:</label>
                        <select class="form-control" asp-for="employee" asp-items="employeeUsernames">
                        </select>
                    </div>
                    <div class="col-md-4">
                        @if (bpmRole == "pm" || bpmRole == "hr_admin")
                        {
                            <div class="form-group">
                                <button type="submit" class="btn btn-success"><span class="glyphicon glyphicon-play-circle"></span> Start It!</button>

                            </div>
                        }
                        else
                        {
                            <p class="alert-danger">Please login as @pmUsername or @hrUsername to start an evaluation of an employee.</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>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

