Ejemplo n.º 1
0
        public ActionResult Reporting_Hangar()
        {
            var context = new AllDbContext();
            List <HangarDetails> hangar = context.Hangars.ToList();

            return(View(hangar));
        }
Ejemplo n.º 2
0
        public ActionResult Reporting_Planes()
        {
            var context = new AllDbContext();
            List <PlaneDetails> planes = context.Planes.ToList();

            return(View("Reporting_Planes", planes));
        }
        public ActionResult FlightDetailsUpdate(FlightPlanDetails flight)
        {
            if (ModelState.IsValid)
            {
                AllDbContext    context = new AllDbContext();
                PlanesDbContext db      = new PlanesDbContext();

                ViewBag.PlaneID = new SelectList(db.Planes.Where(n => n.isAllotted == false), "PlaneID", "PlaneID");


                var items = context.Planes.Where(n => n.isAllotted == false);
                ViewBag.PlaneId = items;
                if (items != null)
                {
                    ViewBag.data = items;
                }
                var pilot = db.Planes.Where(n => n.PlaneID == flight.PlaneID);
                foreach (var i in pilot)
                {
                    i.isAllotted = true;
                }
                flight.isActive = true;
                flight.PilotID  = User.Identity.GetUserName();
                context.Flights.Add(flight);
                db.SaveChanges();
                context.SaveChanges();
                TempData["savedFlight"] = "Flight Details Added to Database Sucessfull!";
                return(RedirectToAction("Index", "Pilot"));
            }
            return(View());
        }
        public ActionResult AllotmentOfPlanes(PlanesAllotments hangar)
        {
            AllDbContext db        = new AllDbContext();
            var          user      = db.Hangars.Where(n => n.HangerName == hangar.HangarName);
            var          planeUser = db.Planes.Where(n => n.PlaneID == hangar.PlaneID);

            if (ModelState.IsValid)
            {
                foreach (var i in user)
                {
                    i.isPlaneAllocated = true;
                }
                foreach (var j in planeUser)
                {
                    j.isAllotted = true;
                }
                hangar.isPlaneAllocated = true;
                hangar.ManagerID        = User.Identity.GetUserName().ToString();
                db.Entry(hangar).State  = EntityState.Added;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.HangarName = new SelectList(db.Hangars.Where(n => n.isPlaneAllocated == false && n.isActive == true), "HangerName", "HangerName");
            ViewBag.PlaneID    = new SelectList(db.Planes.Where(n => n.isAllotted == false), "PlaneID", "planeID");
            return(View(hangar));
        }
Ejemplo n.º 5
0
        public ActionResult AddHangar(HangarDetails hangar)
        {
            if (ModelState.IsValid)
            {
                AllDbContext   context  = new AllDbContext();
                var            isUnique = context.Hangars.Where(n => n.HangerName == hangar.HangerName);
                AdminDbContext db       = new AdminDbContext();
                foreach (var i in isUnique)
                {
                    if (i.HangerName == hangar.HangerName)
                    {
                        ViewData["HError"] = "Hangar Name Already Exists";
                        return(View(hangar));
                    }
                }
                ViewBag.AdminID = new SelectList(db.Admin, "AdminID", "AdminID");
                var items = context.Admins.Select(n => n.AdminID);
                if (items != null)
                {
                    ViewBag.data = items;
                }

                hangar.AdminID = User.Identity.GetUserName();
                context.Hangars.Add(hangar);
                context.SaveChanges();
                TempData["hangarSaved"] = "Hangar Details Added to Database Successfully";
                return(RedirectToAction("Hangars", "Admin"));
            }
            return(View());
        }
Ejemplo n.º 6
0
        async void Init()
        {
            await Task.Run(() => context = new AllDbContext());

            UpdateLists();
            //RoleCombo.ItemsSource = Enum.GetValues(typeof(Role));
        }
Ejemplo n.º 7
0
 public ToursViewModel(PageService pageservice,
                       AllDbContext dbContext,
                       FieldsGenerator fieldsGenerator,
                       CloneItemsSerivce cloneItems,
                       EventBus eventBus) : base(pageservice, dbContext, fieldsGenerator, cloneItems, eventBus)
 {
 }
Ejemplo n.º 8
0
        public ActionResult Reporting()
        {
            var context = new AllDbContext();
            List <PlaneDetails>      planes = context.Planes.ToList();
            List <FlightPlanDetails> hangar = context.Flights.ToList();

            return(View());
        }
Ejemplo n.º 9
0
 public UserRegisterService(AllDbContext allDbContext,
                            UserService userService,
                            MapperService mapper)
 {
     this.db          = allDbContext;
     this.userService = userService;
     this.mapper      = mapper;
 }
Ejemplo n.º 10
0
        public static async Task ExecuteStatement(AllDbContext context, string text, SqlParameter[][] @params)
        {
            var db = context.Database;

            foreach (var param in @params)
            {
                await db.ExecuteSqlCommandAsync(text, param);
            }
        }
        public ActionResult AllotmentOfPlanes()
        {
            AllDbContext db = new AllDbContext();

            ViewBag.HangarName = new SelectList(db.Hangars.Where(n => n.isPlaneAllocated == false && n.isActive == true), "HangerName", "HangerName");
            ViewBag.PlaneID    = new SelectList(db.Planes.Where(n => n.isAllotted == false), "PlaneID", "planeID");
            ViewBag.ManagerID  = User.Identity.GetUserName();
            return(View());
        }
Ejemplo n.º 12
0
        public static async Task ExecuteServices()
        {
            using (AllDbContext context = new AllDbContext())
            {
                await context.Services.LoadAsync();

                context.Services.RemoveRange(context.Services);

                await ExecuteStatement(context, ServicesTableStatement, ServicesTableParams);
            }
        }
Ejemplo n.º 13
0
 public void StartLoading()
 {
     t = new Thread(() =>
     {
         _context = new AllDbContext();
         _context.Services.Load();
         IsLoaded = true;
         t        = null;
     });
     t.Start();
 }
Ejemplo n.º 14
0
        public ActionResult UpdateHangar(int?id)
        {
            var db    = new AllDbContext();
            var model = db.Hangars.FirstOrDefault(r => r.ID == id);

            if (model == null)
            {
                return(HttpNotFound());
            }
            return(View(model));
        }
Ejemplo n.º 15
0
 protected ItemsViewModel(PageService pageservice,
                          AllDbContext dbContext,
                          Services.FieldsGenerator fieldsGenerator,
                          CloneItemsSerivce cloneItems, EventBus eventBus) : base(pageservice)
 {
     this.pageservice     = pageservice;
     this.dbContext       = dbContext;
     this.fieldsGenerator = fieldsGenerator;
     this.cloneItems      = cloneItems;
     this.eventBus        = eventBus;
     Init();
 }
Ejemplo n.º 16
0
        public ActionResult AddSchedule(PilotSchedule ps)
        {
            var db = new AllDbContext();

            if (ModelState.IsValid)
            {
                db.Entry(ps).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            ViewBag.PilotID = new SelectList(db.Pilots, "PilotID", "PilotID", ps.PilotID);
            return(View(ps));
        }
Ejemplo n.º 17
0
 public AdminViewModel(PageManager pageservice,
                       AllDbContext dbContext,
                       Validator validator,
                       OrderService orderService,
                       FileBrowserService fileBrowser,
                       MapperService mapper) : base(pageservice)
 {
     this.dbContext    = dbContext;
     this.validator    = validator;
     this.orderService = orderService;
     this.fileBrowser  = fileBrowser;
     this.mapper       = mapper;
     Init();
 }
Ejemplo n.º 18
0
        public ActionResult UpdateHangar(HangarDetails hangar)
        {
            var db    = new AllDbContext();
            var entry = db.Entry(hangar);

            if (ModelState.IsValid)
            {
                entry.State = EntityState.Modified;
                db.SaveChanges();
                TempData["HangarUpdate"] = "Hangar Details Updated Successfully";
                return(RedirectToAction("Hangars", "Admin"));
            }
            return(View(entry));
        }
Ejemplo n.º 19
0
        public async Task LoadAsync()
        {
            Thread thread = new Thread(() => { DbContext = new AllDbContext(); DbContext.Autos.Load(); _loaded = true; });

            thread.Start();

            await Task.Run(() =>
            {
                while (!_loaded)
                {
                    Task.Delay(100);
                }
            });
        }
Ejemplo n.º 20
0
        public async Task ReloadAsync(int clId)
        {
            using (var context = new AllDbContext())
            {
                await context.Orders.Where(x => x.ClientId.Equals(clId)).Include(x => x.Services).Include(x => x.OrderDetail).LoadAsync();

                _orders = context.Orders.Local.ToList();

                foreach (var ord in _orders.Where(x => x.Services.Any(y => y.NeedDetails)))
                {
                    await context.Entry(ord.OrderDetail).Reference(x => x.Style).LoadAsync();
                }
            }
        }
Ejemplo n.º 21
0
        public static async Task ExecuteEmployee()
        {
            using (AllDbContext context = new AllDbContext())
            {
                await context.Employees.LoadAsync();

                await context.EmployeeAdmins.LoadAsync();

                context.EmployeeAdmins.RemoveRange(context.EmployeeAdmins);
                context.Employees.RemoveRange(context.Employees);

                await ExecuteStatement(context, EmployeesTableStatement, EmployeesTableParams);
                await ExecuteStatement(context, EmpAdminTableStatement, EmpAdminsTableParams);
            }
        }
Ejemplo n.º 22
0
        public async Task <bool> TryLogin(string login, string password, bool isAdmin)
        {
            await Task.Run(() => dbContext = new AllDbContext());

            IUser user;

            if (isAdmin)
            {
                //await dbContext.EmployeeAdmins.LoadAsync();
                //user = await dbContext.EmployeeAdmins.FirstOrDefaultAsync(u =>
                //   string.Compare(login, u.Login, false) == 0 &&
                //   string.Compare(password, u.Password, false) == 0);

                user = new EmployeeAdmin
                {
                    Employee = new Employee
                    {
                        Name = "Администратор"
                    },
                    Id = 1,
                };
            }
            else
            {
                await dbContext.Clients.LoadAsync();

                user = await dbContext.Clients.FirstOrDefaultAsync(u =>
                                                                   (string.Compare(login, u.Login, false) == 0 || string.Compare(login, u.Email, false) == 0) &&
                                                                   string.Compare(password, u.Password, false) == 0);
            }



            if (user != null)
            {
                userService.SetupUser(user, isAdmin);
            }
            else
            {
                ErrorMessage = isAdmin ? "Данные для входа некорректные" : "Пользователь не найден";
            }

            return(user != null);
        }
Ejemplo n.º 23
0
        public ActionResult AddSchedule(int?id)
        {
            var db = new AdminDbContext();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            var           db1 = new AllDbContext();
            PilotSchedule ps  = db1.Pilot_schedule.Find(id);

            if (ps == null)
            {
                return(HttpNotFound());
            }
            ViewBag.PilotID = new SelectList(db1.Pilots, "PilotID", "PilotID", ps.PilotID);
            return(View(ps));
        }
Ejemplo n.º 24
0
 public ServicesService(AllDbContext dbContext, MapperService mapper)
 {
     this.dbContext = dbContext;
     this.mapper    = mapper;
 }
Ejemplo n.º 25
0
 public FieldsGenerator(AllDbContext allDbContext)
 {
     this.allDbContext = allDbContext;
 }
Ejemplo n.º 26
0
 public LoginService(AllDbContext dbContext, UserService userService, MapperService mapper)
 {
     this.dbContext   = dbContext;
     this.userService = userService;
     this.mapper      = mapper;
 }
Ejemplo n.º 27
0
 public ClientOrders(ICurrentUserService currentUser, DAL.AllDbContext dbContext)
 {
     _client        = currentUser.CurrentUser as Client;
     this.dbContext = dbContext;
 }
Ejemplo n.º 28
0
 public OrderService(AllDbContext dbContext, MapperService mapperService)
 {
     this.dbContext = dbContext;
     this.mapper = mapperService;
 }
Ejemplo n.º 29
0
 public OrderService(AllDbContext dbContext, MapperService mapperService, InsurancesService insurancesService)
 {
     this.dbContext         = dbContext;
     this.mapper            = mapperService;
     this.insurancesService = insurancesService;
 }
Ejemplo n.º 30
0
 public AdminViewModel(PageService pageservice, AllDbContext dbContext) : base(pageservice)
 {
     this.dbContext = dbContext;
     Init();
 }