Exemple #1
0
 public bool ValidateCheckDeletion(Check check)
 {
     MyLogger.Instance().Log("Validate Check's deletion -- CALLED", "Service", "INFO");
     try
     {
         lock (x)
         {
             using (ProjectDBContext dBContext = new ProjectDBContext())
             {
                 Check toDelete = dBContext.Checks.ToList().Find(c => c.Id == check.Id);
                 if (dBContext.Checks.ToList().Exists(x => x.Id == check.Id))
                 {
                     MyLogger.Instance().Log("Validate Check's deletion -- SUCCESS", "Service", "INFO");
                     return(true);
                 }
                 else
                 {
                     MyLogger.Instance().Log("Validate Check's deletion -- FAIL", "Service", "ERROR");
                     return(false);
                 }
             }
         }
     }
     catch
     {
         MyLogger.Instance().Log("Validate Check's deletion -- ERROR", "Service", "FATAL");
         return(false);
     }
 }
 //Single Category
 public Category GetCategory(int ID)
 {
     using (var context = new ProjectDBContext())
     {
         return(context.Categories.Find(ID));
     }
 }
 //All Categories
 public List <Category> GetCategories()
 {
     using (var context = new ProjectDBContext())
     {
         return(context.Categories.ToList());
     }
 }
 //Single Product
 public Product GetProduct(int ID)
 {
     using (var context = new ProjectDBContext())
     {
         return(context.Products.Find(ID));
     }
 }
Exemple #5
0
 public List <User> GetAllUsers()
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         return(_db.Users.ToList());
     }
 }
 public EntryWindow(ProjectDBContext db, Entry entry = null)
 {
     this.entry = entry;
     if (this.entry == null)
     {
         this.entry = new Entry()
         {
             Date = DateTime.Now
         }
     }
     ;
     this.db = db;
     InitializeComponent();
     db.CarWash.Load();
     carWash_cb.ItemsSource = db.CarWash.Local.ToObservableCollection();
     db.ClientPhone.Load();
     phone_cb.ItemsSource = db.ClientPhone.Local.ToObservableCollection();
     db.Car.Load();
     car_cb.ItemsSource = db.Car.Local.ToObservableCollection();
     db.Service.Load();
     services_lb.ItemsSource = db.Service.Local.ToObservableCollection();
     foreach (EntryService item in this.entry.EntryService)
     {
         services_lb.SelectedItems.Add(item.Service);
     }
     ChangeTime(this.entry.Date);
     OnPropertyChanged(nameof(Time));
 }
 public QuizController(IQuizRepo quizrepo, ProjectDBContext context, UserManager <Person> UserMgr, IQuestionsRepo questionsRepo)
 {
     this.quizrepo      = quizrepo;
     this.context       = context;
     _userManager       = UserMgr;
     this.questionsRepo = questionsRepo;
 }
 public ClientReportWindow(ProjectDBContext db)
 {
     this.db = db;
     db.Client.Load();
     InitializeComponent();
     clients_cb.ItemsSource = this.db.Client.Local.ToArray();
 }
 public QuestionsController(IQuestionsRepo questionsRepo, ProjectDBContext context, IQuizRepo quizrepo, IHistoryRepo historyRepo)
 {
     this.questionsRepo = questionsRepo;
     this.context       = context;
     this.quizrepo      = quizrepo;
     this.historyRepo   = historyRepo;
 }
Exemple #10
0
 public bool ValidateCheckChange(Check check)
 {
     MyLogger.Instance().Log("Validate Check -- CALLED", "Service", "INFO");
     try
     {
         lock (x)
         {
             using (ProjectDBContext dBContext = new ProjectDBContext())
             {
                 Check toValidate = dBContext.Checks.ToList().Find(x => x.Id == check.Id);
                 if (DateTime.Compare(check.Datetime, dBContext.Checks.ToList().Find(x => x.Id == check.Id).Datetime) != 0)
                 {
                     MyLogger.Instance().Log("Validate Check -- FAILED", "Service", "INFO");
                     return(false);
                 }
                 else
                 {
                     MyLogger.Instance().Log("Validate Check -- SUCCESS", "Service", "INFO");
                     return(true);
                 }
             }
         }
     }
     catch
     {
         MyLogger.Instance().Log("Validate Check -- ERROR", "Service", "FATAL");
         return(false);
     }
 }
        private void Seed()
        {
            using (var context = new ProjectDBContext(options))
            {
                context.Database.EnsureDeleted();
                context.Database.EnsureCreated();

                context.Pattern.AddRange(
                    new Pattern
                {
                    Id          = 2,
                    PatternData = "10110111"
                },
                    new Pattern
                {
                    Id          = 3,
                    PatternData = "00010001"
                }


                    );

                context.SaveChanges();
            }
        }
Exemple #12
0
 /// <summary>
 ///
 /// </summary>
 /// <returns></returns>
 public List <Model.Task> GetAllTasks()
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         return(_db.Tasks.ToList());
     }
 }
 public AnswersController(IQuestionsRepo questionsRepo, ProjectDBContext context, IQuizRepo quizrepo, IAnswersRepo answerRepo)
 {
     this.questionsRepo = questionsRepo;
     this.context       = context;
     this.quizrepo      = quizrepo;
     this.answerRepo    = answerRepo;
 }
 public List <Project> GetAllProjects()
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         return(_db.Projects.ToList());
     }
 }
Exemple #15
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="newTask"></param>
 public void AddTask(Model.Task newTask)
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         _db.Tasks.Add(newTask);
         _db.SaveChanges();
     }
 }
Exemple #16
0
 public bool AddUser(User newUser)
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         _db.Users.Add(newUser);
         _db.SaveChanges();
         return(true);
     }
 }
 public bool AddProject(Project newProject)
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         _db.Projects.Add(newProject);
         _db.SaveChanges();
         return(true);
     }
 }
        //All Products
        public List <Product> GetProducts()
        {
            //var context = new ProjectDBContext();
            //return context.Products.ToList();

            using (var context = new ProjectDBContext())
            {
                return(context.Products.Include(x => x.Category).ToList());
            }
        }
 public ProductWindow(ProjectDBContext db, Product product = null)
 {
     this.product = product;
     if (this.product == null)
     {
         this.product = new Product();
     }
     this.db = db;
     InitializeComponent();
 }
        public IActionResult Get(string id)
        {
            var client = new ProjectDBContext().Client.FirstOrDefault(n => n.Id == Convert.ToInt16(id));

            if (client == null)
            {
                return(new NotFoundObjectResult(client));
            }
            return(Ok(client));
        }
        public async Task GetUsersSampleSetsByIDAsync_ShouldReturnUserSampleSets()
        {
            int id = 1;
            ProjectDBContext projectDBContext = new ProjectDBContext(options);
            ProjectRepoDB    projectRepoDB    = new ProjectRepoDB(projectDBContext);

            var result = await projectRepoDB.GetUsersSampleSetsByIDAsync(id);

            Assert.Equal(1, result.Id);
        }
Exemple #22
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public Model.Task GetTaskByID(string id)
 {
     using (ProjectDBContext _db = new ProjectDBContext())
     {
         List <Model.Task> allTasks = (from task1 in _db.Tasks
                                       select task1).ToList();
         Model.Task task = allTasks.Where(a => a.Task_ID == id).FirstOrDefault();
         return(task);
     }
 }
        public async Task GetUsersSampleSetsByUserIDAsync_ShouldReturnUserSampleSets()
        {
            int id = 2;
            ProjectDBContext projectDBContext = new ProjectDBContext(options);
            ProjectRepoDB    projectRepoDB    = new ProjectRepoDB(projectDBContext);

            var result = await projectRepoDB.GetUsersSampleSetsByUserIDAsync(id);

            Assert.Single(result);
        }
Exemple #24
0
        /// <summary>
        /// /
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public List <Model.Task> GetAllTasksByProjectID(string id)
        {
            using (ProjectDBContext _db = new ProjectDBContext())
            {
                List <Model.Task> allTasks = (from task1 in _db.Tasks
                                              select task1).ToList();

                return(allTasks.Where(a => a.Project_ID == id).ToList());
            }
        }
 public ServiceWindow(ProjectDBContext db, Service service = null)
 {
     this.service = service;
     if (this.service == null)
     {
         this.service = new Service();
     }
     this.db = db;
     InitializeComponent();
 }
        public IActionResult Get(int id)
        {
            var Project = new ProjectDBContext().Project.FirstOrDefault(n => n.Id == id);

            if (Project == null)
            {
                return(new NotFoundObjectResult(Project));
            }
            return(Ok(Project));
        }
 public void UpdateCategory(Category category)
 {
     using (var context = new ProjectDBContext())
     {
         //Update category
         context.Entry(category).State = System.Data.Entity.EntityState.Modified;
         //Save Changes
         context.SaveChanges();
     }
 }
 public CarWashWindow(ProjectDBContext db, CarWash cw = null)
 {
     this.cw = cw;
     if (this.cw == null)
     {
         this.cw = new CarWash();
     }
     this.db = db;
     InitializeComponent();
 }
 public void UpdateProduct(Product product)
 {
     using (var context = new ProjectDBContext())
     {
         //Update Product
         context.Entry(product).State = System.Data.Entity.EntityState.Modified;
         //Save Changes
         context.SaveChanges();
     }
 }
 public void SaveCategory(Category category)
 {
     using (var context = new ProjectDBContext())
     {
         //Add category
         context.Categories.Add(category);
         //Save Changes
         context.SaveChanges();
     }
 }