Example #1
0
 public static Restriction ToRestriction(this RestrictionModel restriction)
 {
     return(new Restriction()
     {
         Type = (RestrictionType)restriction.Type,
         Value = restriction.Value,
     });
 }
Example #2
0
        protected override RestrictionModel MapRestriction(DataRow row)
        {
            var restriction = new RestrictionModel();

            restriction.CollectionName    = row.GetString("CollectionName");
            restriction.RestrictionName   = row.GetString("RestrictionName");
            restriction.RestrictionNumber = row.GetInt("RestrictionNumber");

            return(restriction);
        }
        public void AddEmployeeForm_AddRestriction(object e)
        {
            DateTime today          = DateTime.Today;
            var      newRestriction = new RestrictionModel();

            newRestriction.Name      = _selectedRestriction.Name;
            newRestriction.EndDate   = _newRestrictionEndDate;
            newRestriction.Id        = _selectedRestriction.Id;
            newRestriction.BeginDate = today;
            Restrictions.Add(newRestriction);
        }
Example #4
0
 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);
     }
 }