Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
 public ActionResult Create(Job job)
 {
     if (ModelState.IsValid)
     {
         using (var db = new TaskDBContext())
         {
             db.Job.Add(job);
             db.SaveChanges();
         }
     }
     return(RedirectToAction($"GetById/{job.Id}"));
 }
Ejemplo n.º 5
0
        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}"));
            }
        }
Ejemplo n.º 6
0
 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"));
     }
 }
Ejemplo n.º 7
0
        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());
        }
Ejemplo n.º 8
0
 public LogUserController(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 9
0
 public ToDoListController(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 10
0
 public TasksRepository(TaskDBContext db)
 {
     this.db = db;
 }
Ejemplo n.º 11
0
 public CityService(TaskDBContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 12
0
 public UserRepository(TaskDBContext db)
 {
     this.db = db;
 }
Ejemplo n.º 13
0
 public DistrictService(TaskDBContext context, IMapper mapper)
 {
     _context = context;
     _mapper  = mapper;
 }
Ejemplo n.º 14
0
 public DepartmentRepository(TaskDBContext taskDB)
 {
     _taskDB = taskDB;
 }
Ejemplo n.º 15
0
 public AuthorController(TaskDBContext taskDbContext)
 {
     _taskDbContext = taskDbContext;
 }
Ejemplo n.º 16
0
 public ContactLogRepo(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 17
0
 public AuthController(IJwtAuthenticationManager jwtAuthenticationManager, TaskDBContext taskDbContext)
 {
     this.jwtAuthenticationManager = jwtAuthenticationManager;
     this._taskDbContext           = taskDbContext;
 }
Ejemplo n.º 18
0
 public ProjectsController(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 19
0
 public TaskRepository()
 {
     _db = new TaskDBContext();
 }
Ejemplo n.º 20
0
 public TaskController(TaskDBContext taskDbContext)
 {
     _taskDbContext = taskDbContext;
 }
 public UserInfoesController(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 22
0
 public TasksController(TaskDBContext context)
 {
     _context = context;
 }
Ejemplo n.º 23
0
 public VisitsRepository(TaskDBContext Context)
 {
     _Context = Context;
 }
Ejemplo n.º 24
0
 public UserRepository(TaskDBContext taskDB)
 {
     _taskDB = taskDB;
 }
Ejemplo n.º 25
0
 public TaskController(TaskDBContext db)
 {
     this.db = db;
 }
Ejemplo n.º 26
0
 public CustomerRepository(TaskDBContext Context)
 {
     _Context = Context;
 }
Ejemplo n.º 27
0
 public SalesRepository(TaskDBContext Context)
 {
     _Context = Context;
 }