Пример #1
0
        public EquipmentViewModel GetElement(EquipmentBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var equipment = context.Equipment
                                .Include(rec => rec.Employee)
                                .Include(rec => rec.Supplier)
                                .Include(rec => rec.Type)
                                .FirstOrDefault(rec => rec.Id == model.Id);
                return(equipment != null ?
                       new EquipmentViewModel
                {
                    Id = equipment.Id,
                    Name = equipment.Name,
                    Specifications = equipment.Specifications,
                    ReceiptDate = equipment.ReceiptDate,
                    State = equipment.State,
                    TypeId = equipment.TypeId,
                    SupplierId = equipment.SupplierId,
                    EmployeeId = equipment.EmployeeId,
                    TypeName = equipment.Type.Name,
                    EmployeeName = equipment.EmployeeId.HasValue ? equipment.Employee.Name : string.Empty,
                    SupplierOrganizationName = equipment.Supplier.OrganizationName
                } : null);
            }
        }
Пример #2
0
        public List <EquipmentSoftwareViewModel> GetFilteredList(EquipmentSoftwareBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                return(context.EquipmentSoftware
                       .Include(rec => rec.Software)
                       .Include(rec => rec.Equipment)
                       .ThenInclude(rec => rec.Type)
                       .Where(rec => !string.IsNullOrEmpty(model.EquipmentName) && rec.Equipment.Name.Contains(model.EquipmentName))
                       .Select(rec => new EquipmentSoftwareViewModel
                {
                    Id = rec.Id,
                    EquipmentId = rec.EquipmentId,
                    SoftwareId = rec.SoftwareId,
                    EquipmentName = rec.Equipment.Name,
                    SoftwareName = rec.Software.Name,
                    EquipmentType = rec.Equipment.Type.Name
                }).ToList());
            }
        }
Пример #3
0
        public List <EquipmentViewModel> GetFilteredList(EquipmentBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                return(context.Equipment
                       .Include(rec => rec.Employee)
                       .Include(rec => rec.Supplier)
                       .Include(rec => rec.Type)
                       .Where(rec => model.DateFrom.HasValue && model.DateTo.HasValue && rec.ReceiptDate >= model.DateFrom.Value.Date && rec.ReceiptDate <= model.DateTo.Value.Date)
                       .Select(rec => new EquipmentViewModel
                {
                    Id = rec.Id,
                    Name = rec.Name,
                    Specifications = rec.Specifications,
                    ReceiptDate = rec.ReceiptDate,
                    State = rec.State,
                    TypeId = rec.TypeId,
                    EmployeeId = rec.EmployeeId,
                    SupplierId = rec.SupplierId,
                    TypeName = rec.Type.Name,
                    EmployeeName = rec.EmployeeId.HasValue ? rec.Employee.Name : string.Empty,
                    SupplierOrganizationName = rec.Supplier.OrganizationName
                }).ToList());
            }
        }
Пример #4
0
        public EquipmentSoftwareViewModel GetElement(EquipmentSoftwareBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var eqSoft = context.EquipmentSoftware
                             .Include(rec => rec.Software)
                             .Include(rec => rec.Equipment)
                             .ThenInclude(rec => rec.Type)
                             .FirstOrDefault(rec => rec.Id == model.Id);
                return(eqSoft != null ?
                       new EquipmentSoftwareViewModel
                {
                    Id = eqSoft.Id,
                    SoftwareId = eqSoft.SoftwareId,
                    EquipmentId = eqSoft.EquipmentId,
                    SoftwareName = eqSoft.Software.Name,
                    EquipmentName = eqSoft.Equipment.Name,
                    EquipmentType = eqSoft.Equipment.Type.Name
                } : null);
            }
        }
Пример #5
0
 public void Insert(EmployeeBindingModel model)
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         context.Employee.Add(CreateModel(model, new Employee()));
         context.SaveChanges();
     }
 }
Пример #6
0
 public void Insert(SupplierBindingModel model)
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         context.Supplier.Add(CreateModel(model, new Supplier()));
         context.SaveChanges();
     }
 }
Пример #7
0
 public List <EmployeeViewModel> GetFullList()
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         return(context.Employee
                .Select(rec => new EmployeeViewModel
         {
             Id = rec.Id,
             Name = rec.Name
         }).ToList());
     }
 }
Пример #8
0
 public List <SoftwareViewModel> GetFullList()
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         return(context.Software
                .Select(rec => new SoftwareViewModel
         {
             Id = rec.Id,
             Name = rec.Name,
             License_type = rec.LicenseType
         }).ToList());
     }
 }
Пример #9
0
        public void Update(TypeBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                var type = context.Type.FirstOrDefault(rec => rec.Id == model.Id);

                if (type == null)
                {
                    throw new Exception("Тип не найден");
                }
                CreateModel(model, type);
                context.SaveChanges();
            }
        }
Пример #10
0
        public void Update(SoftwareBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                var software = context.Software.FirstOrDefault(rec => rec.Id == model.Id);

                if (software == null)
                {
                    throw new Exception("ПО не найдено");
                }
                CreateModel(model, software);
                context.SaveChanges();
            }
        }
Пример #11
0
        public void Update(EmployeeBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                var employee = context.Employee.FirstOrDefault(rec => rec.Id == model.Id);

                if (employee == null)
                {
                    throw new Exception("Сотрудник не найден");
                }
                CreateModel(model, employee);
                context.SaveChanges();
            }
        }
Пример #12
0
        public void Update(SupplierBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                var supplier = context.Supplier.FirstOrDefault(rec => rec.Id == model.Id);

                if (supplier == null)
                {
                    throw new Exception("Поставщик не найден");
                }
                CreateModel(model, supplier);
                context.SaveChanges();
            }
        }
Пример #13
0
        public void Update(EquipmentSoftwareBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                var eqSoft = context.EquipmentSoftware.FirstOrDefault(rec => rec.Id == model.Id);

                if (eqSoft == null)
                {
                    throw new Exception("Данная пара \"Техника - ПО\" не найдена");
                }
                CreateModel(model, eqSoft);
                context.SaveChanges();
            }
        }
Пример #14
0
 public List <SupplierViewModel> GetFullList()
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         return(context.Supplier
                .Select(rec => new SupplierViewModel
         {
             Id = rec.Id,
             OrganizationName = rec.OrganizationName,
             EmployeeName = rec.EmployeeName,
             Address = rec.Address,
             PhoneNumber = rec.PhoneNumber
         }).ToList());
     }
 }
Пример #15
0
        public void Delete(SupplierBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                Supplier supplier = context.Supplier.FirstOrDefault(rec => rec.Id == model.Id);

                if (supplier != null)
                {
                    context.Supplier.Remove(supplier);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Поставщик не найден");
                }
            }
        }
Пример #16
0
        public void Delete(TypeBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                Models.Type type = context.Type.FirstOrDefault(rec => rec.Id == model.Id);

                if (type != null)
                {
                    context.Type.Remove(type);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Тип не найден");
                }
            }
        }
Пример #17
0
        public void Delete(SoftwareBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                Software software = context.Software.FirstOrDefault(rec => rec.Id == model.Id);

                if (software != null)
                {
                    context.Software.Remove(software);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("ПО не найдено");
                }
            }
        }
Пример #18
0
        public void Delete(EquipmentSoftwareBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                EquipmentSoftware eqSoft = context.EquipmentSoftware.FirstOrDefault(rec => rec.Id == model.Id);

                if (eqSoft != null)
                {
                    context.EquipmentSoftware.Remove(eqSoft);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Данная пара \"Техника - ПО\" не найдена");
                }
            }
        }
Пример #19
0
        public void Delete(EquipmentBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                Equipment equipment = context.Equipment.FirstOrDefault(rec => rec.Id == model.Id);

                if (equipment != null)
                {
                    context.Equipment.Remove(equipment);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Техника не найдена");
                }
            }
        }
Пример #20
0
        public void Delete(EmployeeBindingModel model)
        {
            using (var context = new ComputingEquipmentDatabase())
            {
                Employee employee = context.Employee.FirstOrDefault(rec => rec.Id == model.Id);

                if (employee != null)
                {
                    context.Employee.Remove(employee);
                    context.SaveChanges();
                }
                else
                {
                    throw new Exception("Сотрудник не найден");
                }
            }
        }
Пример #21
0
        public List <EmployeeViewModel> GetFilteredList(EmployeeBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                return(context.Employee
                       .Where(rec => rec.Name.Contains(model.Name))
                       .Select(rec => new EmployeeViewModel
                {
                    Id = rec.Id,
                    Name = rec.Name
                }).ToList());
            }
        }
Пример #22
0
        public TypeViewModel GetElement(TypeBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var type = context.Type
                           .FirstOrDefault(rec => rec.Id == model.Id);
                return(type != null ?
                       new TypeViewModel
                {
                    Id = type.Id,
                    Name = type.Name,
                } : null);
            }
        }
Пример #23
0
 public List <EquipmentSoftwareViewModel> GetFullList()
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         return(context.EquipmentSoftware
                .Include(rec => rec.Software)
                .Include(rec => rec.Equipment)
                .ThenInclude(rec => rec.Type)
                .Select(rec => new EquipmentSoftwareViewModel
         {
             Id = rec.Id,
             EquipmentId = rec.EquipmentId,
             SoftwareId = rec.SoftwareId,
             EquipmentName = rec.Equipment.Name,
             SoftwareName = rec.Software.Name,
             EquipmentType = rec.Equipment.Type.Name
         }).ToList());
     }
 }
Пример #24
0
        public List <SoftwareViewModel> GetFilteredList(SoftwareBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                return(context.Software
                       .Where(rec => rec.LicenseType == model.License_type)
                       .Select(rec => new SoftwareViewModel
                {
                    Id = rec.Id,
                    Name = rec.Name,
                    License_type = rec.LicenseType
                }).ToList());
            }
        }
Пример #25
0
        public EmployeeViewModel GetElement(EmployeeBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var employee = context.Employee
                               .FirstOrDefault(rec => rec.Id == model.Id);
                return(employee != null ?
                       new EmployeeViewModel
                {
                    Id = employee.Id,
                    Name = employee.Name,
                } : null);
            }
        }
Пример #26
0
        public SoftwareViewModel GetElement(SoftwareBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var software = context.Software
                               .FirstOrDefault(rec => rec.Id == model.Id);
                return(software != null ?
                       new SoftwareViewModel
                {
                    Id = software.Id,
                    Name = software.Name,
                    License_type = software.LicenseType
                } : null);
            }
        }
Пример #27
0
        public SupplierViewModel GetElement(SupplierBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                var supplier = context.Supplier
                               .FirstOrDefault(rec => rec.Id == model.Id);
                return(supplier != null ?
                       new SupplierViewModel
                {
                    Id = supplier.Id,
                    OrganizationName = supplier.OrganizationName,
                    EmployeeName = supplier.EmployeeName,
                    Address = supplier.Address,
                    PhoneNumber = supplier.PhoneNumber
                } : null);
            }
        }
Пример #28
0
        public List <SupplierViewModel> GetFilteredList(SupplierBindingModel model)
        {
            if (model == null)
            {
                return(null);
            }

            using (var context = new ComputingEquipmentDatabase())
            {
                return(context.Supplier
                       .Where(rec => !string.IsNullOrEmpty(model.OrganizationName) && rec.OrganizationName.Contains(model.OrganizationName) ||
                              !string.IsNullOrEmpty(model.Address) && rec.Address.Contains(model.Address))
                       .Select(rec => new SupplierViewModel
                {
                    Id = rec.Id,
                    OrganizationName = rec.OrganizationName,
                    EmployeeName = rec.EmployeeName,
                    Address = rec.Address,
                    PhoneNumber = rec.PhoneNumber
                }).ToList());
            }
        }
Пример #29
0
 public List <EquipmentViewModel> GetFullList()
 {
     using (var context = new ComputingEquipmentDatabase())
     {
         return(context.Equipment
                .Include(rec => rec.Employee)
                .Include(rec => rec.Supplier)
                .Include(rec => rec.Type)
                .Select(rec => new EquipmentViewModel
         {
             Id = rec.Id,
             Name = rec.Name,
             Specifications = rec.Specifications,
             ReceiptDate = rec.ReceiptDate,
             State = rec.State,
             TypeId = rec.TypeId,
             EmployeeId = rec.EmployeeId,
             SupplierId = rec.SupplierId,
             TypeName = rec.Type.Name,
             EmployeeName = rec.EmployeeId.HasValue ? rec.Employee.Name : string.Empty,
             SupplierOrganizationName = rec.Supplier.OrganizationName
         }).ToList());
     }
 }