コード例 #1
0
        public ActionResult Edit(int id, CertificationModel cert)
        {
            try
            {
                InitializePageData();

                if (ModelState.IsValid)
                {
                    if (certService.Exists(cert.Name, cert.CertificationID))
                    {
                        DisplayWarningMessage($"Certification Name '{cert.Name}' is duplicate");
                        return(View(cert));
                    }

                    CertificationDto certModel = Mapper.Map <CertificationModel, CertificationDto>(cert);
                    certService.Update(certModel);
                    DisplaySuccessMessage($"Certification '{cert.Name}' details have been modified successfully");
                    return(RedirectToAction("List", new { taID = Session["TAID"] }));
                }
            }
            catch (Exception exp)
            {
                DisplayUpdateErrorMessage(exp);
            }
            return(View(cert));
        }
コード例 #2
0
        public ActionResult Create(CertificationModel cert)
        {
            try
            {
                InitializePageData();

                if (ModelState.IsValid)
                {
                    if (certService.Exists(cert.Name))
                    {
                        DisplayWarningMessage($"The Certification Name '{cert.Name}' is duplicate");
                        return(View(cert));
                    }
                    CertificationDto certModel = Mapper.Map <CertificationModel, CertificationDto>(cert);
                    certService.AddCertificate(certModel);
                    DisplaySuccessMessage($"New Certification '{cert.Name}' has been stored successfully");
                    return(RedirectToAction("List", new { taID = Session["TAID"] }));
                }
            }
            catch (Exception exp)
            {
                DisplayLoadErrorMessage(exp);
            }
            return(View(cert));
        }
コード例 #3
0
        // GET: Certs/Edit/5
        public ActionResult Edit(int?id)
        {
            CertificationModel cert = new CertificationModel();

            try
            {
                InitializePageData();

                if (!id.HasValue)
                {
                    DisplayWarningMessage("Looks like, the ID is missing in your request");
                    return(RedirectToAction("List", new { taID = Session["TAID"] }));
                }

                if (!certService.Exists(id.Value))
                {
                    DisplayWarningMessage($"Sorry, We couldn't find the Certification with ID: {id.Value}");
                    return(RedirectToAction("List", new { taID = Session["TAID"] }));
                }

                CertificationDto practiceDto = certService.GetByID(id.Value);
                cert = Mapper.Map <CertificationDto, CertificationModel>(practiceDto);
            }
            catch (Exception exp)
            {
                DisplayReadErrorMessage(exp);
            }

            return(View(cert));
        }
コード例 #4
0
        public void SaveCertification()
        {
            //arrange
            IFlowManager flowManager   = serviceProvider.GetRequiredService <IFlowManager>();
            var          certification = flowManager.EnrollmentRepository.GetAsync <CertificationModel, Certification>
                                         (
                s => s.UserId == 1
                                         ).Result.Single();

            certification.EntityState         = LogicBuilder.Domain.EntityStateType.Modified;
            flowManager.FlowDataCache.Request = new SaveEntityRequest {
                Entity = certification
            };

            //act
            System.Diagnostics.Stopwatch stopWatch = System.Diagnostics.Stopwatch.StartNew();
            flowManager.Start("savecertification");
            stopWatch.Stop();
            this.output.WriteLine("Saving valid certification  = {0}", stopWatch.Elapsed.TotalMilliseconds);

            //assert
            Assert.True(flowManager.FlowDataCache.Response.Success);
            Assert.Empty(flowManager.FlowDataCache.Response.ErrorMessages);

            CertificationModel model = (CertificationModel)((SaveEntityResponse)flowManager.FlowDataCache.Response).Entity;

            Assert.True(model.CertificateStatementChecked);
        }
コード例 #5
0
        public async Task <IActionResult> Update(CertificationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }


            if (Request.Form.Files != null && Request.Form.Files.Count > 0)
            {
                string savedFileName = string.Empty;
                string path          = Path.Combine(_hostingEnvironment.WebRootPath, FolderName.CERTIFICATION_IMAGE_FOLDER);
                savedFileName = Helper.UploadImage(Request.Form.Files[0], path, model.CertificationId.ToString());
                _logger.LogDebug("Certification logo updated successfully.", model.CertificationId);
                model.CertificationImage = savedFileName;
            }

            if ((await _certificationBLL.UpdateAsync(model)) > 0)
            {
                _logger.LogDebug("Certification updated successfully.", model.CertificationId);
                ViewData.SetViewData(new StatusModel {
                    TransactionStatus = StatusEnum.Succeed, StatusMessage = string.Format(Message.UPDATE_SUCCESS, "Certification")
                }, HelpingVariable.STATUS);
            }
            else
            {
                _logger.LogDebug("Certification updation failed.", model.CertificationId);
                ViewData.SetViewData(new StatusModel {
                    TransactionStatus = StatusEnum.Failed, StatusMessage = string.Format(Message.UPDATE_FAILURE, "certification")
                }, HelpingVariable.STATUS);
            }

            return(View(model));
        }
コード例 #6
0
        public void AddEmployeeForm_AddCertification(object e)
        {
            var newCertification = new CertificationModel();

            newCertification.Name    = SelectedCertification.Name;
            newCertification.EndDate = _newCertificationExpirationDate;
            newCertification.Id      = SelectedCertification.Id;
            Certifications.Add(newCertification);
        }
コード例 #7
0
    private CertificationDatabase()
    {
        m_pCertificationList = new List <CertificationModel>();

        m_szDbFilePath = System.Web.HttpContext.Current.Server.MapPath(ModelParam.CERIIFICATION_PATH);
        m_pDoc.Load(m_szDbFilePath);

        XmlNodeList list = m_pDoc.SelectNodes(@"certifications/certification");

        foreach (XmlNode tmp in list)
        {
            CertificationModel certification = new CertificationModel(tmp, this);
            m_pCertificationList.Add(certification);
        }
    }
コード例 #8
0
        public ActionResult EditCertification(string certificationName)
        {
            JneCommSitesDataLayer.JneCommSitesDataBaseEntities _dbContext = new JneCommSitesDataLayer.JneCommSitesDataBaseEntities();
            Models.CertificationModel newCertificationModel = new CertificationModel();
            var queryCertification = (from p in _dbContext.T_Certifications
                                      where p.vCertificationName == certificationName
                                      select p).FirstOrDefault();

            if (queryCertification == null)
            {
                RedirectToAction("CertificationsList", "Maintenance");
            }
            newCertificationModel.certificationpDescription = queryCertification.vCertificationDescription;
            newCertificationModel.certificationName         = queryCertification.vCertificationName;
            return(View(newCertificationModel));
        }
コード例 #9
0
        public void SaveCertification()
        {
            //arrange
            IFlowManager flowManager = serviceProvider.GetRequiredService <IFlowManager>();
            var          user        = new UserModel
            {
                UserName    = "******",
                EntityState = LogicBuilder.Domain.EntityStateType.Added
            };

            flowManager.FlowDataCache.Request = new SaveEntityRequest {
                Entity = user
            };
            flowManager.Start("saveuser");
            Assert.True(user.UserId > 1);

            var certification = new CertificationModel
            {
                UserId      = user.UserId,
                EntityState = LogicBuilder.Domain.EntityStateType.Added,
                CertificateStatementChecked = true,
                DeclarationStatementChecked = true,
                PolicyStatementsChecked     = true
            };

            flowManager.FlowDataCache.Request = new SaveEntityRequest {
                Entity = certification
            };

            //act
            System.Diagnostics.Stopwatch stopWatch = System.Diagnostics.Stopwatch.StartNew();
            flowManager.Start("savecertification");
            stopWatch.Stop();
            this.output.WriteLine("Saving valid certification  = {0}", stopWatch.Elapsed.TotalMilliseconds);

            //assert
            Assert.True(flowManager.FlowDataCache.Response.Success);
            Assert.Empty(flowManager.FlowDataCache.Response.ErrorMessages);

            CertificationModel model = (CertificationModel)((SaveEntityResponse)flowManager.FlowDataCache.Response).Entity;

            Assert.True(model.CertificateStatementChecked);
        }
コード例 #10
0
        public async Task <IActionResult> Create(CertificationModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            if (await _certificationBLL.SaveAsync(model) > 0)
            {
                _logger.LogDebug("Certification created successfully.", model.CertificationId);
                TempData.SetStatus(new StatusModel {
                    TransactionStatus = StatusEnum.Succeed, StatusMessage = string.Format(Message.CREATE_SUCCESS, "Certification")
                });
                string savedFileName = string.Empty;

                if (Request.Form.Files != null && Request.Form.Files.Count > 0)
                {
                    string path = Path.Combine(_hostingEnvironment.WebRootPath, FolderName.CERTIFICATION_IMAGE_FOLDER);
                    savedFileName = Helper.UploadImage(Request.Form.Files[0], path, model.CertificationId.ToString());
                    _logger.LogDebug("Certification logo uploaded successfully.", model.CertificationId);
                    model.CertificationImage = savedFileName;

                    await _certificationBLL.UpdateAsync(model);

                    _logger.LogDebug("Certification logo name updated successfully.", model.CertificationId);
                }
            }
            else
            {
                _logger.LogDebug("Certification creation failed.");
                TempData.SetStatus(new StatusModel {
                    TransactionStatus = StatusEnum.Failed, StatusMessage = string.Format(Message.CREATE_FAILURE, "certification")
                });
            }

            return(RedirectToAction("Update", new { id = model.CertificationId }));
        }
コード例 #11
0
 public IViewComponentResult Invoke(CertificationModel model)
 {
     return(View("_ItemCertification", model));
 }
コード例 #12
0
ファイル: GetData.cs プロジェクト: heschides/RobinBradley2021
 public static async Task <ObservableCollection <EmployeeModel> > EmployeeQueryAsync()
 {
     using (var connection = new System.Data.SqlClient.SqlConnection(CnnString(database)))
     {
         var employees = new Dictionary <int, EmployeeModel>();
         await connection.QueryAsync <EmployeeModel>("dbo.spGetEmployeeData_All", new[]
         {
             typeof(EmployeeModel),
             typeof(EmailModel),
             typeof(JobTitleModel),
             typeof(PhoneModel),
             typeof(DepartmentModel),
             typeof(EmployeeStatusModel),
             typeof(CitationModel),
             typeof(CertificationModel),
             typeof(EquipmentAssignmentRecordModel),
             typeof(RestrictionModel)
         }
                                                     , obj =>
         {
             EmployeeModel employeeModel           = obj[0] as EmployeeModel;
             EmailModel emailModel                 = obj[1] as EmailModel;
             JobTitleModel titleModel              = obj[2] as JobTitleModel;
             PhoneModel phoneModel                 = obj[3] as PhoneModel;
             DepartmentModel departmentModel       = obj[4] as DepartmentModel;
             EmployeeStatusModel statusModel       = obj[5] as EmployeeStatusModel;
             CitationModel citationModel           = obj[6] as CitationModel;
             CertificationModel certificationModel = obj[7] as CertificationModel;
             EquipmentAssignmentRecordModel equipmentAssignmentRecord = obj[8] as EquipmentAssignmentRecordModel;
             RestrictionModel restrictionModel = obj[9] as RestrictionModel;
             //employeemodel
             var employeeEntity = new EmployeeModel();
             if (!employees.TryGetValue(employeeModel.Id, out employeeEntity))
             {
                 employees.Add(employeeModel.Id, employeeEntity = employeeModel);
             }
             //list<emailmodel>
             if (employeeEntity.Emails == null)
             {
                 employeeEntity.Emails = new ObservableCollection <EmailModel>();
             }
             if (emailModel != null)
             {
                 if (!employeeEntity.Emails.Any(x => x.Id == emailModel.Id))
                 {
                     employeeEntity.Emails.Add(emailModel);
                 }
             }
             //phonemodel
             if (employeeEntity.Phones == null)
             {
                 employeeEntity.Phones = new ObservableCollection <PhoneModel>();
             }
             if (phoneModel != null)
             {
                 if (!employeeEntity.Phones.Any(x => x.Id == phoneModel.Id))
                 {
                     employeeEntity.Phones.Add(phoneModel);
                 }
             }
             //title
             if (employeeEntity.JobTitle == null)
             {
                 if (titleModel != null)
                 {
                     employeeEntity.JobTitle = titleModel;
                 }
             }
             //department
             if (employeeEntity.Department == null)
             {
                 if (departmentModel != null)
                 {
                     employeeEntity.Department = departmentModel;
                 }
             }
             //status
             if (employeeEntity.Status == null)
             {
                 if (statusModel != null)
                 {
                     employeeEntity.Status = statusModel;
                 }
             }
             //citation
             if (employeeEntity.Citations == null)
             {
                 employeeEntity.Citations = new ObservableCollection <CitationModel>();
             }
             if (citationModel != null)
             {
                 if (!employeeEntity.Citations.Any(x => x.Id == citationModel.Id))
                 {
                     employeeEntity.Citations.Add(citationModel);
                 }
             }
             //certification
             if (employeeEntity.Certifications == null)
             {
                 employeeEntity.Certifications = new ObservableCollection <CertificationModel>();
             }
             if (certificationModel != null)
             {
                 if (!employeeEntity.Certifications.Any(x => x.Id == certificationModel.Id))
                 {
                     employeeEntity.Certifications.Add(certificationModel);
                 }
             }
             //restriction
             if (employeeEntity.Restrictions == null)
             {
                 employeeEntity.Restrictions = new ObservableCollection <RestrictionModel>();
             }
             if (restrictionModel != null)
             {
                 if (!employeeEntity.Restrictions.Any(x => x.Id == restrictionModel.Id))
                 {
                     employeeEntity.Restrictions.Add(restrictionModel);
                 }
             }
             //equipment record
             if (employeeEntity.EquipmentAssignments == null)
             {
                 employeeEntity.EquipmentAssignments = new ObservableCollection <EquipmentAssignmentRecordModel>();
             }
             if (equipmentAssignmentRecord != null)
             {
                 if (!employeeEntity.EquipmentAssignments.Any(x => x.Id == equipmentAssignmentRecord.Id))
                 {
                     employeeEntity.EquipmentAssignments.Add(equipmentAssignmentRecord);
                 }
             }
             return(employeeEntity);
         });;
         var result             = employees.Values.ToList();
         var employeeCollection = new ObservableCollection <EmployeeModel>(result);
         return(employeeCollection);
     }
 }
コード例 #13
0
        public async Task <ObservableCollection <EmployeeModel> > GetEmployeeList()
        {
            using (IDbConnection connection = new System.Data.SqlClient.SqlConnection(GlobalConfig.CnnString("WorkDeskDB")))
            {
                var sql       = @"SELECT e.id, e.FirstName, e.LastName, e.Nickname, e.HireDate,
                                em.id as ID, em.Address, em.Type, 
                                jt.id as ID, jt.Name, 
                                p.id as ID, p.Number, p.Type,
                                d.id as ID, d.Name,
                                es.id as ID, es.Name,
						        ecitt.id as ID, cit.Name, ecitt.Date, ecitt.Description,
                                ecert.id as ID, cet.Name, cet.Description, ecert.InitialDate, ecert.EmployeeID,
						        eqa.id as ID, eq.InventoryID, eq.Description, eqa.DateOut, eqa.DateIn, eqa.ConditionOut, eqa.ConditionIn, eqa.DueDate   


                        FROM dbo.Employees e 
                        LEFT JOIN dbo.Emails em
                        ON em.EmployeeID = e.id
                        LEFT JOIN dbo.JobTitles jt                           
                        ON e.JobTitleID = jt.id
                        LEFT JOIN Phones p
                        ON p.EmployeeID = e.id
                        LEFT JOIN dbo.Departments d
                        ON e.DepartmentID = d.id
                        LEFT JOIN dbo.EmployeeStatus es  
                        ON e.StatusID = es.id
				        LEFT JOIN dbo.EmployeeCitationType ecitt
				        ON e.id = ecitt.EmployeeID
				        LEFT JOIN dbo.CitationTypes cit
				        ON ecitt.CitationTypeID = cit.id
				        LEFT JOIN dbo.EmployeeCertificationType ecert
				        ON e.id = ecert.EmployeeID
				        LEFT JOIN dbo.CertificationType cet
				        ON ecert.NameID = cet.id
				        LEFT JOIN EquipmentAssignments eqa
				        ON eqa.EmployeeID = e.id
				        LEFT JOIN Equipment eq
				        ON eqa.EquipmentID = eq.id"                ;
                var employees = new Dictionary <int, EmployeeModel>();
                await connection.QueryAsync <EmployeeModel>
                    (sql,
                    new[]
                {
                    typeof(EmployeeModel),
                    typeof(EmailModel),
                    typeof(TitleModel),
                    typeof(PhoneModel),
                    typeof(DepartmentModel),
                    typeof(EmployeeStatusModel),
                    typeof(CitationModel),
                    typeof(CertificationModel),
                    typeof(EquipmentAssignmentRecordModel)
                }
                    , obj =>
                {
                    EmployeeModel employeeModel           = obj[0] as EmployeeModel;
                    EmailModel emailModel                 = obj[1] as EmailModel;
                    TitleModel titleModel                 = obj[2] as TitleModel;
                    PhoneModel phoneModel                 = obj[3] as PhoneModel;
                    DepartmentModel departmentModel       = obj[4] as DepartmentModel;
                    EmployeeStatusModel statusModel       = obj[5] as EmployeeStatusModel;
                    CitationModel citationModel           = obj[6] as CitationModel;
                    CertificationModel certificationModel = obj[7] as CertificationModel;
                    EquipmentAssignmentRecordModel equipmentAssignmentRecord = obj[8] as EquipmentAssignmentRecordModel;

                    //employeemodel
                    EmployeeModel employeeEntity = new EmployeeModel();
                    if (!employees.TryGetValue(employeeModel.ID, out employeeEntity))
                    {
                        employees.Add(employeeModel.ID, employeeEntity = employeeModel);
                    }

                    //list<emailmodel>
                    if (employeeEntity.Emails == null)
                    {
                        employeeEntity.Emails = new ObservableCollection <EmailModel>();
                    }
                    if (emailModel != null)
                    {
                        if (!employeeEntity.Emails.Any(x => x.ID == emailModel.ID))
                        {
                            employeeEntity.Emails.Add(emailModel);
                        }
                    }

                    //phonemodel
                    if (employeeEntity.Phones == null)
                    {
                        employeeEntity.Phones = new ObservableCollection <PhoneModel>();
                    }
                    if (phoneModel != null)
                    {
                        if (!employeeEntity.Phones.Any(x => x.ID == phoneModel.ID))
                        {
                            employeeEntity.Phones.Add(phoneModel);
                        }
                    }

                    //title
                    if (employeeEntity.JobTitle == null)
                    {
                        if (titleModel != null)
                        {
                            employeeEntity.JobTitle = titleModel;
                        }
                    }

                    //department
                    if (employeeEntity.Department == null)
                    {
                        if (departmentModel != null)
                        {
                            employeeEntity.Department = departmentModel;
                        }
                    }

                    //status
                    if (employeeEntity.JobStatus == null)
                    {
                        if (statusModel != null)
                        {
                            employeeEntity.JobStatus = statusModel;
                        }
                    }

                    //citation
                    if (employeeEntity.Citations == null)
                    {
                        employeeEntity.Citations = new ObservableCollection <CitationModel>();
                    }
                    if (citationModel != null)
                    {
                        if (!employeeEntity.Citations.Any(x => x.ID == citationModel.ID))
                        {
                            employeeEntity.Citations.Add(citationModel);
                        }
                    }

                    //certification
                    if (employeeEntity.Certifications == null)
                    {
                        employeeEntity.Certifications = new ObservableCollection <CertificationModel>();
                    }
                    if (certificationModel != null)
                    {
                        if (!employeeEntity.Certifications.Any(x => x.ID == certificationModel.ID))
                        {
                            employeeEntity.Certifications.Add(certificationModel);
                        }
                    }

                    //equipment record
                    if (employeeEntity.EquipmentAssignments == null)
                    {
                        employeeEntity.EquipmentAssignments = new ObservableCollection <EquipmentAssignmentRecordModel>();
                    }
                    if (equipmentAssignmentRecord != null)
                    {
                        if (!employeeEntity.EquipmentAssignments.Any(x => x.ID == equipmentAssignmentRecord.ID))
                        {
                            employeeEntity.EquipmentAssignments.Add(equipmentAssignmentRecord);
                        }
                    }
                    return(employeeEntity);
                });;

                var result = employees.Values.ToList();
                ObservableCollection <EmployeeModel> employeeCollection = new ObservableCollection <EmployeeModel>(result);
                return(employeeCollection);
            }
        }