示例#1
0
        public DriverViewModel()
        {
            Driverss = new ObservableCollection <Drivers>();
            using (ModelDB md = new ModelDB())
            {
                var licences = md.Licences.ToList();
                var temp     = md.Drivers.ToList();

                foreach (var item in temp)
                {
                    if (licences[item.ID - 1].Name == item.Name &&
                        licences[item.ID - 1].ExpireDate.Value.Year == licences[item.ID - 1].LicenceDate.Value.Year)
                    {
                        item.Status = "Изъят";
                    }
                    else if (licences[item.ID - 1].Name == item.Name && licences[item.ID - 1].ExpireDate < DateTime.Now &&
                             licences[item.ID - 1].LicenceDate.Value.Year != licences[item.ID - 1].ExpireDate.Value.Year)
                    {
                        item.Status = "Утратил силу";
                    }
                    else
                    {
                        item.Status = "Активен";
                    }

                    item.Photo = $@"{AppDomain.CurrentDomain.BaseDirectory}/Assets/" + item.Photo;
                    Driverss.Add(item);
                    CountObject();
                }
            }
        }
示例#2
0
 public void Update()
 {
     using (ModelDB md = new ModelDB())
     {
         md.Entry(SelectedDriver).State = System.Data.Entity.EntityState.Modified;
         md.SaveChanges();
     }
 }