Example #1
0
        static void Main(string[] args)
        {
            //List<User> mechanics = new ServiserDbContext().Users
            //   .Where(x=>x.CustomerProfile.Id==null ).ToList();

            //foreach(User u in mechanics)
            //{
            //    System.Console.WriteLine(u.FirstName+"   "+u.MechanicProfile.Id);
            //}
            //System.Console.WriteLine("Seeding...");
            ServiserDbContext db = new ServiserDbContext();

            // double d = 5;
            //List<User> user = db.Users.Where(x=>((DateTime)DateTime.Now-(DateTime)x.RegisterationDateTime).TotalSeconds>d).ToList();
            //foreach(User user1 in user)
            {
                //  System.Console.WriteLine(user1.FirstName);
            }

            //System.Console.WriteLine((DateTime.Now-user.RegisterationDateTime).TotalSeconds);


            //    while (db.Database.Exists())
            //  {
            //      System.Console.WriteLine("Database Already Exists. Manually Delete the database and hit Enter.");
            //    System.Console.ReadLine();
            // }

            new ServiserDbInitialSeed().Run();

            //System.Console.WriteLine("Seeding Done.");
            //System.Console.ReadLine();
        }
Example #2
0
        // GET: Admin/Mechanic
        public ActionResult Index()
        {
            IdentityRole role = RoleService.GetRoleByName(RoleService.MECHANIC);

            List <User> mechanics = new ServiserDbContext().Users
                                    .Where(x => x.Roles.Select(y => y.RoleId).Contains(role.Id)).ToList();

            return(View(mechanics));
        }
Example #3
0
        public ActionResult Edit(AccountEditViewModel accountEditViewModel, HttpPostedFileBase profileImage)
        {
            ServiserDbContext db = new ServiserDbContext();
            User user            = User.Identity.GetUser(true);

            if (user.Id == accountEditViewModel.UserId)
            {
                user.FirstName   = accountEditViewModel.FirstName;
                user.LastName    = accountEditViewModel.LastName;
                user.Email       = accountEditViewModel.Email;
                user.PhoneNumber = accountEditViewModel.PhoneNumber;
                user.UserName    = accountEditViewModel.Email;
            }
            if (user.MechanicProfile != null && user.MechanicProfile.Id == accountEditViewModel.MechanicProfileId)
            {
                user.MechanicProfile.CNIC = accountEditViewModel.CNIC;
            }
            if (user.CustomerProfile != null && user.CustomerProfile.Id == accountEditViewModel.CustomerProfileId)
            {
            }


            if (profileImage.ContentLength > 0)
            {
                string remoteDirectoryPath = "~/Data_Files/UserProfileImages/";

                string remoteFilePath = remoteDirectoryPath +
                                        Guid.NewGuid().ToString() +
                                        Path.GetFileName(profileImage.FileName);

                string localPath = Server.MapPath(remoteFilePath);

                Directory.CreateDirectory(Server.MapPath(remoteDirectoryPath));

                profileImage.SaveAs(localPath);

                if (user.ProfileImageUrl != null && !String.IsNullOrWhiteSpace(user.ProfileImageUrl))
                {
                    string localFilePath = Server.MapPath(user.ProfileImageUrl);
                    if (System.IO.File.Exists(localFilePath))
                    {
                        System.IO.File.Delete(localFilePath);
                        user.ProfileImageUrl = null;
                    }
                }

                user.ProfileImageUrl = remoteFilePath;
            }

            db.Entry(user).State = EntityState.Modified;
            db.SaveChanges();

            return(RedirectToAction("Index", "Home"));
        }
Example #4
0
        public ActionResult GenerateBill()
        {
            ServiserDbContext db            = new ServiserDbContext();
            Problems          problemsModel = new Problems();

            problemsModel.BikeProblems = db.VehicleProblems
                                         .Where(x => x.VehicleType.Name == VehicleTypeService.BIKE)
                                         .ToList();
            problemsModel.CarProblems = db.VehicleProblems
                                        .Where(x => x.VehicleType.Name == VehicleTypeService.CAR)
                                        .ToList();
            return(View(problemsModel));
        }
Example #5
0
        public ActionResult Pricing()
        {
            ServiserDbContext     db           = new ServiserDbContext();
            List <VehicleProblem> bikeproblems = db.VehicleProblems.Where(x => x.VehicleType.Name == "Bike").ToList();
            List <VehicleProblem> carproblems  = db.VehicleProblems.Where(x => x.VehicleType.Name == "Car").ToList();

            Problems problemsModel = new Problems();

            problemsModel.BikeProblems = bikeproblems;
            problemsModel.CarProblems  = carproblems;

            return(View(problemsModel));
        }
Example #6
0
        public static User GetUser(this IIdentity user, Boolean eagerLoad = false)
        {
            string            id = user.GetUserId();
            ServiserDbContext db = new ServiserDbContext();

            User u = eagerLoad ?
                     db.Users.Where(x => x.Id == id)
                     .Include(x => x.MechanicProfile)
                     .Include(x => x.CustomerProfile)
                     .Include(x => x.Roles)
                     .FirstOrDefault()
                :
                     db.Users.Where(x => x.Id == id).FirstOrDefault();

            return(u);
        }
Example #7
0
        static void Main(string[] args)
        {
            ServiserDbContext db = new ServiserDbContext();
            List<VehicleProblem> lis = db.VehicleProblems.Include(v => v.VehicleType).ToList();
          //  List<VehicleProblem> lis = vehicleProblems.ToList();
            foreach (VehicleProblem d in lis)
            {
                System.Console.WriteLine(d.Name + "   " + d.EstimatedPrice + " ==> " + d.VehicleTypeId);
            }
            //System.Console.WriteLine("Seeding...");

            //ServiserDbContext db = new ServiserDbContext();

            //while (db.Database.Exists())
            //{
            //    System.Console.WriteLine("Database Already Exists. Manually Delete the database and hit Enter.");
            //    System.Console.ReadLine();
            //}

            //new ServiserDbInitialSeed().Run();

            //System.Console.WriteLine("Seeding Done.");
            //System.Console.ReadLine();
        }
Example #8
0
 public void VerifySelectedProblems(int[] Problems)
 {
     ServiserDbContext     db = new ServiserDbContext();
     List <VehicleProblem> vehicleProblems = db.VehicleProblems.Where(x => Problems.Contains(x.Id)).ToList();
 }
 public ServiserDbInitialSeed()
 {
     DbContext = new ServiserDbContext();
 }