public IActionResult ViewDelegateTempDeptHead()
        {
            if (!HttpContext.Session.GetString("username").IsNullOrEmpty())
            {
                empCheck = JsonConvert.DeserializeObject <Employee>(HttpContext.Session.GetString("employee")) as Employee;

                if (empCheck.EmployeeType.EmployeeTypeName == "Department Head")
                {
                    DelegationViewModel dVModel = new DelegationViewModel();
                    dVModel.employee         = empCheck;
                    dVModel.DepartmentHead   = empCheck;
                    dVModel.DeptEmployeeList = empService.GetEmployeeListByDepartmentExcludingDeptHeadandDeptRep(empCheck.Department);
                    dVModel.dForm            = new DelegationForm()
                    {
                        startDate = System.DateTime.Now.Date.AddDays(1), endDate = System.DateTime.Now.Date.AddDays(2)
                    };

                    return(View("DelegateTempDeptHead", dVModel));
                }
                return(RedirectToAction("Dashboard", "Home"));
            }
            else
            {
                return(RedirectToAction("View", "Home"));
            }
        }
        public List <DelegationViewModel> ConvertToModel(DataTable dt)
        {
            List <DelegationViewModel> model = new List <DelegationViewModel>();

            foreach (DataRow row in dt.Rows)
            {
                DelegationViewModel delegation = new DelegationViewModel();

                //delegation.DelegationID = (row[0] != null || row[0] != DBNull.Value) ? Convert.ToInt32(row[0]) : 0;
                // delegation.DelegationID = (int)row[0];
                delegation.DelegationID   = row[0] != DBNull.Value ? (string)row[0] : "";
                delegation.StartDate      = Convert.ToDateTime(row[1]);
                delegation.EndDate        = Convert.ToDateTime(row[2]);
                delegation.DeptID         = (string)row[3];
                delegation.UserID         = (int)row[4];
                delegation.DepartmentName = (string)row[5];
                delegation.UserName       = (string)row[6];
                model.Add(delegation);
                // delegation.DeptID = row[3] != DBNull.Value ? (string)row[3] : "";
                // delegation.UserID = row[4] != DBNull.Value ? (int)row[4] : 0;


                // delegation.DepartmentName = row[5] != DBNull.Value ? (string)row[5] : "";
                // delegation.UserName = row[6] != DBNull.Value ? (string)row[6] : "";
            }

            return(model);
        }
Exemple #3
0
        private static void ConvertDelegationByAmountToViewModel(this DelegationViewModel viewModel,
                                                                 ClientFieldData[] clientFieldData)
        {
            var chkMinAmounts = clientFieldData.Where(o => o.Name.Equals("chkSetMinAmount"))
                                .ToList();
            var chkMaxAmounts = clientFieldData.Where(o => o.Name.Equals("chkSetMaxAmount"))
                                .ToList();
            var txtMinAmounts = clientFieldData.Where(o => o.Name.Equals("txt_chkSetMinAmount"))
                                .ToList();
            var txtMaxAmounts = clientFieldData.Where(o => o.Name.Equals("txt_chkSetMaxAmount"))
                                .ToList();
            var isValidAmount = chkMinAmounts.Count == chkMaxAmounts.Count &&
                                chkMaxAmounts.Count == txtMinAmounts.Count &&
                                txtMinAmounts.Count == txtMaxAmounts.Count;
            var iDelegateCount = 0;

            foreach (var module in viewModel.AssignPermissionsTask.Modules)
            {
                var moduleView = clientFieldData.FirstOrDefault(o =>
                                                                !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(module.Code));
                if (moduleView != null)
                {
                    module.IsChecked = Convert.ToBoolean(moduleView.Value);
                    foreach (var workflow in module.WorkFlows)
                    {
                        var workflowView = clientFieldData.FirstOrDefault(o =>
                                                                          !string.IsNullOrWhiteSpace(o.Name) && (o.Name.Equals(workflow.Code) ||
                                                                                                                 o.Name.Equals("chkAmount_" + workflow.Code)));
                        if (workflowView != null)
                        {
                            workflow.IsChecked = Convert.ToBoolean(workflowView.Value);
                            if (workflow.DelegateByAmount && !module.HaveRule)
                            {
                                if (isValidAmount && chkMinAmounts.Any() &&
                                    chkMinAmounts.Count > iDelegateCount)
                                {
                                    if (Convert.ToBoolean(chkMinAmounts[iDelegateCount].Value))
                                    {
                                        var     min = txtMinAmounts[iDelegateCount].Value;
                                        decimal minValue;
                                        workflow.MinAmount = decimal.TryParse(min, out minValue)
                                            ? minValue
                                            : (decimal?)null;
                                    }

                                    if (Convert.ToBoolean(chkMaxAmounts[iDelegateCount].Value))
                                    {
                                        var     max = txtMaxAmounts[iDelegateCount].Value;
                                        decimal maxValue;
                                        workflow.MaxAmount = decimal.TryParse(max, out maxValue)
                                            ? maxValue
                                            : (decimal?)null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        public IActionResult ViewDelegateSummary()
        {
            DelegationViewModel dVModel = new DelegationViewModel();

            empCheck               = JsonConvert.DeserializeObject <Employee>(HttpContext.Session.GetString("employee")) as Employee;
            dVModel.employee       = empCheck;
            dVModel.delegationList = delService.FindAllDelegations(empCheck.Department);
            dVModel.DepartmentHead = empService.FindDeptHead(empCheck);
            return(View("DelegateSummary", dVModel));
        }
        public IActionResult ViewDLForm([FromRoute] int id)
        {
            Employee employee = empService.GetEmployeeById(id);

            DelegationViewModel dVModel = new DelegationViewModel();

            dVModel.DepartmentHead = empService.FindDeptHead(employee);
            dVModel.employee       = employee;
            dVModel.dForm          = delegationService.FindDelegationForm(id);
            return(View("DelegateView", dVModel));
        }
        public IActionResult ViewDLForm([FromRoute] int id)
        {
            empCheck = JsonConvert.DeserializeObject <Employee>(HttpContext.Session.GetString("employee")) as Employee;

            DelegationViewModel dVModel = new DelegationViewModel();

            dVModel.DepartmentHead = empService.FindDeptHead(empCheck);
            dVModel.employee       = empCheck;
            dVModel.dForm          = delService.FindDelegationForm(id);
            return(View("DelegateView", dVModel));
        }
        public IActionResult SaveDeptRep2([FromBody] DelegationViewModel dVModel)
        {
            bool status = delegationService.AssignDeptRep2(dVModel.delegateComment, dVModel.delegatee, dVModel.employee);

            if (status is true)
            {
                return(new JsonResult(new { success = "Success" }));
            }
            else
            {
                return(new JsonResult(new { success = "Failure" }));
            }
        }
        public IActionResult SaveTempDeptHead([FromBody] DelegationViewModel dvm)
        {
            bool status = delegationService.AssignTempDeptHead(dvm.delegateComment, dvm.delegatee, dvm.employee, dvm.startDate, dvm.endDate);

            if (status == true)
            {
                return(Ok(dvm));
            }
            else
            {
                return(null);
            }
        }
        public IActionResult SaveTempDeptHead([FromBody] DelegationViewModel dVModel)
        {
            bool status = delService.AssignTempDeptHead(dVModel.delegateComment, dVModel.delegatee, dVModel.employee, dVModel.startDate, dVModel.endDate);

            if (status is true)
            {
                return(new JsonResult(new { success = "Success" }));
            }
            else
            {
                return(new JsonResult(new { success = "Failure" }));
            }
        }
 public IActionResult DelegateDeptRep()
 {
     empCheck = JsonConvert.DeserializeObject <Employee>(HttpContext.Session.GetString("employee")) as Employee;
     if (empCheck.EmployeeType.EmployeeTypeName == "Department Head" || empCheck.TempDeptHeadType.EmployeeTypeName == "Temporary Department Head")
     {
         DelegationViewModel dVModel = new DelegationViewModel();
         dVModel.DepartmentHead   = empService.FindDeptHead(empCheck);
         dVModel.DeptEmployeeList = empService.GetEmpListExcludingDeptHeadAndTempDeptHeadandDeptRep(empCheck.Department);
         dVModel.employee         = empCheck;
         return(View("DelegateDeptRep", dVModel));
     }
     return(RedirectToAction("Dashboard", "Home"));
 }
        public IActionResult UpdateDLForm([FromBody] DelegationViewModel dVModel)
        {
            bool status = delService.UpdateDLFormStartandEndDate(dVModel.dForm);

            if (status is true)
            {
                return(new JsonResult(new { success = "Success" }));
            }
            else
            {
                return(new JsonResult(new { success = "Failure" }));
            }
        }
        public IActionResult ViewDelegateSummary(int id)
        {
            Employee employee = empService.GetEmployeeById(id);

            if (employee.EmployeeType.EmployeeTypeName.Equals("Department Head"))
            {
                DelegationViewModel dVModel = new DelegationViewModel();
                dVModel.employee       = employee;
                dVModel.delegationList = delegationService.FindAllDelegations(employee.Department);
                dVModel.DepartmentHead = empService.FindDeptHead(employee);
                return(Ok(dVModel));
            }
            else
            {
                return(null);
            }
        }
        public IActionResult ViewDelegateTempDeptHead(int id)
        {
            Employee employee = empService.GetEmployeeById(id);

            if (employee.EmployeeType.EmployeeTypeName.Equals("Department Head"))
            {
                DelegationViewModel dVModel = new DelegationViewModel();
                dVModel.employee         = employee;
                dVModel.DepartmentHead   = employee;
                dVModel.DeptEmployeeList = empService.GetEmployeeListByDepartmentExcludingDeptHeadandDeptRep(employee.Department);
                return(Ok(dVModel));
            }
            else
            {
                return(null);
            }
        }
Exemple #14
0
        public static void UpdateDelegationViewModel(this DelegationViewModel viewModel,
                                                     ClientFieldData[] clientFieldData)
        {
            viewModel.TableDelegator = ConvertTodelegatorTableViewModel(clientFieldData);

            foreach (var country in viewModel.AssignSubDelegation.Countries)
            {
                var countryView = clientFieldData.FirstOrDefault(o =>
                                                                 !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(country.CountryControlName));
                if (countryView != null)
                {
                    country.CountrySelected = Convert.ToBoolean(countryView.Value);
                }
            }

            foreach (var division in viewModel.AssignSubDelegation.Divisions)
            {
                var divisionView = clientFieldData.FirstOrDefault(o =>
                                                                  !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals(division.DivisionControlName));
                if (divisionView != null)
                {
                    division.DivisionSelected = Convert.ToBoolean(divisionView.Value);
                }
            }

            viewModel.AssignSubDelegation.AllDivisionSelected =
                !viewModel.AssignSubDelegation.Divisions.Any(x => !x.DivisionSelected);

            foreach (var operationType in viewModel.AssignSubDelegation.OperationTypes)
            {
                var operationTypeView = clientFieldData
                                        .FirstOrDefault(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                                        o.Name.Equals(operationType.OperationTypeControlName));
                if (operationTypeView != null)
                {
                    operationType.OperationTypeSelected =
                        Convert.ToBoolean(operationTypeView.Value);
                }
            }

            viewModel.ConvertDelegationByAmountToViewModel(clientFieldData);

            var assignedUser = clientFieldData.FirstOrDefault(o =>
                                                              !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals("SearchDelegateUser"));

            if (assignedUser != null)
            {
                viewModel.UserToAssign.AssignedUserName = assignedUser.Value;
            }

            var startDate = clientFieldData.FirstOrDefault(o =>
                                                           !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals("startDate"));

            if (startDate != null)
            {
                viewModel.UserToAssign.StartDate = Convert.ToDateTime(startDate.Value);
            }

            var endDate = clientFieldData.FirstOrDefault(o =>
                                                         !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals("endDate"));

            if (endDate != null)
            {
                viewModel.UserToAssign.EndDate = Convert.ToDateTime(endDate.Value);
            }

            var delegationType = clientFieldData.FirstOrDefault(o =>
                                                                !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals("delegationType"));

            if (delegationType != null)
            {
                viewModel.UserToAssign.Type = Convert.ToInt32(delegationType.Value);
            }

            var delegationReason = clientFieldData.FirstOrDefault(o =>
                                                                  !string.IsNullOrWhiteSpace(o.Name) && o.Name.Equals("delegationReason"));

            if (delegationReason != null)
            {
                viewModel.UserToAssign.Reason = Convert.ToInt32(delegationReason.Value);
            }

            viewModel.CommentsDelegation = ConvertCommentsDelegationViewModel(clientFieldData);
            viewModel.TableDocument      = ConvertToTableDocument(clientFieldData);
            viewModel.ListOfOperations   =
                clientFieldData.FirstOrDefault(o => !string.IsNullOrWhiteSpace(o.Name) &&
                                               o.Name.Equals("operationsToBeSaved")).Value.Split(',')
                .Where(s => !string.IsNullOrWhiteSpace(s)).Distinct().ToList();
        }
 public DelegationInfoPage(DelegationViewModel delegationViewModel)
 {
     InitializeComponent();
     BindingContext = delegationViewModel;
 }
        public ActionResult Index()
        {
            var vm = new DelegationViewModel(this.delegationRepository);

            return(View("Index", vm));
        }
        public ActionResult WriteSql()
        {
            const int NUMBER_OF_DELEGATIONS = 223;
            const int NUMBER_OF_LOCATIONS   = 150;

            var locations = new List <LocationPairerModel>()
            {
                new LocationPairerModel()
                {
                    Name = "McDonalds", Location = LocationType.Restaurant
                },
                new LocationPairerModel()
                {
                    Name = "KFC", Location = LocationType.Restaurant
                },
                new LocationPairerModel()
                {
                    Name = "Happy", Location = LocationType.Restaurant
                },
                new LocationPairerModel()
                {
                    Name = "Soul Kitchen", Location = LocationType.Restaurant
                },
                new LocationPairerModel()
                {
                    Name = "Hilton", Location = LocationType.Hotel
                },
                new LocationPairerModel()
                {
                    Name = "Holiday Inn", Location = LocationType.Hotel
                },
                new LocationPairerModel()
                {
                    Name = "Sheraton", Location = LocationType.Hotel
                },
                new LocationPairerModel()
                {
                    Name = "Endava HQ", Location = LocationType.Office
                },
                new LocationPairerModel()
                {
                    Name = "Space X HQ", Location = LocationType.Office
                },
                new LocationPairerModel()
                {
                    Name = "Ministry of Foreign Affairs", Location = LocationType.Office
                }
            };

            var finalLocations = new List <LocationViewModel>();

            for (int i = 0, k = 0; i < NUMBER_OF_LOCATIONS; i++, k++)
            {
                if (k == locations.Count)
                {
                    k = 0;
                }

                var location = new LocationViewModel()
                {
                    Name       = locations[k].Name + ((i > 9) ? " " + (i / 10) : ""),
                    Longitude  = GetCoord(),
                    Latitude   = GetCoord(),
                    LocationId = (int)locations[k].Location
                };

                using (StreamWriter writer = new StreamWriter(@"C:\Users\patanasov\Desktop\Locations.txt", true))
                {
                    writer.WriteLine(location);
                }
            }

            var finalDelegations = new List <DelegationViewModel>();

            var delegations = new List <DelegationPairerModel>()
            {
                new DelegationPairerModel()
                {
                    Name = "Tech Delegation", Description = "Update technical documentation."
                },
                new DelegationPairerModel()
                {
                    Name = "Greet Delegation", Description = "Prepare greet meeting."
                },
                new DelegationPairerModel()
                {
                    Name = "CEO Delegation", Description = "Plan corporation annual agenda"
                },
                new DelegationPairerModel()
                {
                    Name = "CTO Delegation", Description = "Developing the company''s strategy for using technological resources."
                },
                new DelegationPairerModel()
                {
                    Name = "Internship Comitee", Description = "Start planning for the next group of trainees."
                },
                new DelegationPairerModel()
                {
                    Name = "Presentation Delegation", Description = "Present the company''s next year plan for development."
                },
                new DelegationPairerModel()
                {
                    Name = "Software Delegation", Description = "Develop and implement software."
                },
                new DelegationPairerModel()
                {
                    Name = "Project owners association", Description = "Assisting and providing leadership towards the completion of project tasks."
                },
                new DelegationPairerModel()
                {
                    Name = "Art Delegation", Description = "Teach modern art."
                },
                new DelegationPairerModel()
                {
                    Name = "Sports Delegation", Description = "Change scoring rules."
                }
            };

            for (int i = 0, k = 0; i < NUMBER_OF_DELEGATIONS; i++, k++)
            {
                if (k == delegations.Count)
                {
                    k = 0;
                }

                var startDate = RandomStartDate();
                var endDate   = RandomEndDate(startDate);

                var delegation = new DelegationViewModel()
                {
                    Name        = delegations[k].Name + ((i > 9) ? " " + (i / 10) : ""),
                    Description = delegations[k].Description,
                    StartDate   = startDate.ToString("yyyyMMdd"),
                    EndDate     = endDate.ToString("yyyyMMdd"),
                    AgendaTitle = GetAgendaName(k.ToString()),
                    HostId      = 1,
                    LocationId  = rnd.Next(1, 10)
                };

                using (StreamWriter writer = new StreamWriter(@"C:\Users\patanasov\Desktop\Delegations.txt", true))
                {
                    writer.WriteLine(delegation);
                }
            }

            return(View());
        }