public string GetById(int id) { string text = ""; using (var db = new TaskDBContext()) { Job job = db.Job.FirstOrDefault(x => x.Id == id); text = JsonConvert.SerializeObject(job); } return(text); }
public string GetAll() { string text = ""; using (var db = new TaskDBContext()) { List <Job> allJobs = db.Job.Include("InverseParent").ToList(); text = JsonConvert.SerializeObject(allJobs, Formatting.Indented); } return(text); }
private static void TaskDataInitializer(IServiceProvider serviceProvider) { using (var context = new TaskDBContext( serviceProvider.GetRequiredService <DbContextOptions <TaskDBContext> >())) { if (context.TaskList.Any()) { return; } context.TaskList.AddRange( new TaskListModel { ID = 101, TaskDescription = "Created - Task Cloud Migration", TaskHead = "Cloud Migration", TaskUserId = 101, UpdatedDate = DateTime.Now, TaskChecked = false }, new TaskListModel { ID = 102, TaskDescription = "Created - Task SAAS Migration", TaskHead = "SAAS Migration", TaskUserId = 102, UpdatedDate = DateTime.Now, TaskChecked = false } ); if (context.LogModel.Any()) { return; } context.LogModel.AddRange( new LogModel { ID = 101, UserName = "******", Password = "******" }, new LogModel { ID = 102, UserName = "******", Password = "******" } ); context.SaveChanges(); } }
public ActionResult Create(Job job) { if (ModelState.IsValid) { using (var db = new TaskDBContext()) { db.Job.Add(job); db.SaveChanges(); } } return(RedirectToAction($"GetById/{job.Id}")); }
public ActionResult Edit(Job job) { int id = job.Id; using (var db = new TaskDBContext()) { if (ModelState.IsValid) { db.Entry(job).State = EntityState.Modified; db.SaveChanges(); } return(RedirectToAction($"getbyid/{job.Id}")); } }
public ActionResult Delete(int id) { using (var db = new TaskDBContext()) { Job job = db.Job.Find(id); foreach (var i in db.Job .Where(x => x.ParentId == id)) { i.ParentId = null; } db.Job.Remove(job); db.SaveChanges(); return(RedirectToAction("GetAll")); } }
protected void Application_Start() { #if DEBUG Database.SetInitializer <TaskDBContext>(new TaskDbContextInitializer()); using (var init = new TaskDBContext()) { init.Database.Initialize(force: false); } Database.SetInitializer <SchoolContext>(new SchoolInitializer()); // Database.SetInitializer<ImageContext>(new ImageInitializer()); Database.SetInitializer <MovieContext>(new MovieInitializer()); Log.SingletonLogger.Instance.Attach(new Log.ObserverLogToConsole()); #endif //ModelBinders.Binders.Add(typeof(Appointment), new ValidatingModelBinder()); //ModelValidatorProviders.Providers.Clear(); //ModelValidatorProviders.Providers.Add(new CustomValidationProvider()); //HtmlHelper.ClientValidationEnabled = true; //HtmlHelper.UnobtrusiveJavaScriptEnabled = true; AreaRegistration.RegisterAllAreas(); RegisterGlobalFilters(GlobalFilters.Filters); RegisterRoutes(RouteTable.Routes); DataAnnotationsModelValidatorProvider.RegisterAdapter( typeof(RemoteUID_Attribute), typeof(RemoteValidator)); ControllerBuilder.Current.SetControllerFactory(new NinjectControllerFactory()); ModelBinders.Binders.Add(typeof(Cart), new CartModelBinder()); ModelBinders.Binders.Add(typeof(Appointment), new ValidatingModelBinder()); //odelBinders.Binders.Add(typeof(DateTime), new DateBinder()); }
public LogUserController(TaskDBContext context) { _context = context; }
public ToDoListController(TaskDBContext context) { _context = context; }
public TasksRepository(TaskDBContext db) { this.db = db; }
public CityService(TaskDBContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public UserRepository(TaskDBContext db) { this.db = db; }
public DistrictService(TaskDBContext context, IMapper mapper) { _context = context; _mapper = mapper; }
public DepartmentRepository(TaskDBContext taskDB) { _taskDB = taskDB; }
public AuthorController(TaskDBContext taskDbContext) { _taskDbContext = taskDbContext; }
public ContactLogRepo(TaskDBContext context) { _context = context; }
public AuthController(IJwtAuthenticationManager jwtAuthenticationManager, TaskDBContext taskDbContext) { this.jwtAuthenticationManager = jwtAuthenticationManager; this._taskDbContext = taskDbContext; }
public ProjectsController(TaskDBContext context) { _context = context; }
public TaskRepository() { _db = new TaskDBContext(); }
public TaskController(TaskDBContext taskDbContext) { _taskDbContext = taskDbContext; }
public UserInfoesController(TaskDBContext context) { _context = context; }
public TasksController(TaskDBContext context) { _context = context; }
public VisitsRepository(TaskDBContext Context) { _Context = Context; }
public UserRepository(TaskDBContext taskDB) { _taskDB = taskDB; }
public TaskController(TaskDBContext db) { this.db = db; }
public CustomerRepository(TaskDBContext Context) { _Context = Context; }
public SalesRepository(TaskDBContext Context) { _Context = Context; }