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); } }
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()); } }
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()); } }
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); } }
public void Insert(EmployeeBindingModel model) { using (var context = new ComputingEquipmentDatabase()) { context.Employee.Add(CreateModel(model, new Employee())); context.SaveChanges(); } }
public void Insert(SupplierBindingModel model) { using (var context = new ComputingEquipmentDatabase()) { context.Supplier.Add(CreateModel(model, new Supplier())); context.SaveChanges(); } }
public List <EmployeeViewModel> GetFullList() { using (var context = new ComputingEquipmentDatabase()) { return(context.Employee .Select(rec => new EmployeeViewModel { Id = rec.Id, Name = rec.Name }).ToList()); } }
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()); } }
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(); } }
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(); } }
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(); } }
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(); } }
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(); } }
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()); } }
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("Поставщик не найден"); } } }
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("Тип не найден"); } } }
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("ПО не найдено"); } } }
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("Данная пара \"Техника - ПО\" не найдена"); } } }
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("Техника не найдена"); } } }
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("Сотрудник не найден"); } } }
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()); } }
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); } }
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()); } }
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()); } }
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); } }
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); } }
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); } }
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()); } }
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()); } }