Esempio n. 1
0
        public ActionResult Login(string ID_PENGGUNA, string KAD_PENGENALAN)
        {
            var membershipHelper = new MemberShipHelper();
            var model            = new UserModel();

            // try
            //{
            if (Membership.ValidateUser(ID_PENGGUNA, KAD_PENGENALAN))
            {
                model.ID_PENGGUNA    = ID_PENGGUNA;
                model.KAD_PENGENALAN = KAD_PENGENALAN;
                FormsAuthentication.SetAuthCookie(model.ID_PENGGUNA, false);
                Session["LoginUser"] = membershipHelper.GetUserProfile(model.ID_PENGGUNA, model.KAD_PENGENALAN);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                TempData["Msg"] = "Invalid User Name and Password!";
                return(RedirectToAction("Login"));
            }
            //}
            //catch (Exception e)
            //{
            //    TempData["Msg"] = e.Message;
            //     return RedirectToAction("Login");
            // }
        }
Esempio n. 2
0
        /// <summary>
        /// Method read all members from database
        /// Creates a drop down
        /// </summary>
        /// <param name="strSelectedVehicleType">Value for member that shall be selected. Like 1 or 3</param>
        /// <returns>Returns a drop down list of the members. The list has a selected item</returns>
        public List <SelectListItem> CreateVehicleTypeDropDown(string strSelectedMember)
        {
            List <Membership> lsMembers = GetMembers();

            List <SelectListItem> selectListItems = MemberShipHelper.CreateVehicleTypeDropDown(lsMembers, strSelectedMember);

            return(selectListItems);
        }
Esempio n. 3
0
        public ActionResult Login(UserModel model)
        {
            var membershipHelper = new MemberShipHelper();

            try
            {
                if (Membership.ValidateUser(model.Email, model.Password))
                {
                    FormsAuthentication.SetAuthCookie(model.Email, false);
                    Session["LoginUser"] = membershipHelper.GetUserProfile(model.Email, model.Password);
                    return(RedirectToAction("Index", "Home"));
                }
                else
                {
                    TempData["Msg"] = "Invalid User Name and Password!";
                    return(RedirectToAction("Login"));
                }
            }
            catch (Exception e)
            {
                TempData["Msg"] = e.Message;
                return(RedirectToAction("Login"));
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Method get a list of vehicle and information for the parked vehicle list
        /// </summary>
        /// <param name="iGarageId">Garage id</param>
        /// <returns>List of GarageVehiclesInfoViewModel objects</returns>
        private async Task <List <GarageVehiclesInfoViewModel> > GetParkedVehiclelist(int iGarageId)
        {
            var garage = await dbGarage.Garage.AsNoTracking().Where(i => i.GarageId == iGarageId).FirstOrDefaultAsync();

            var members = await dbGarage.Membership.AsNoTracking().Where(i => i.GarageId == iGarageId).ToListAsync();

            int iNumberOfOccupiedParkingPlaces = await dbGarage.ParkingPlace.Where(g => g.GarageId == garage.GarageId && g.IsOccupied).CountAsync();

            var vehicleTypes = await dbGarage.VehicleType.AsNoTracking().ToListAsync();

            // TODO Check if algo is ok in another test project
            // Now i want to know a members type of membership
            foreach (var member in members)
            {
                member.TypeOfMembersShip = MemberShipHelper.GetTypeOfMemberShip(member);
            }

            var results = await dbGarage.ParkingPlace
                          .Join(
                dbGarage.Vehicle,
                parkingPlace => parkingPlace.ParkingPlaceId,
                vehicle => vehicle.ParkingPlaceId,
                (parkingPlace, vehicle) => new GarageVehiclesInfoViewModel
            {
                VehicleId          = vehicle.VehicleId,
                RegistrationNumber = vehicle.RegistrationNumber,
                CheckInTime        = vehicle.CheckInTime,
                CheckOutTime       = DateTime.Now,
                IsParked           = vehicle.IsParked,
                VehicleTypeId      = vehicle.VehicleTypeId,
                VehicleType        = String.Empty,
                MemberShipId       = vehicle.MembershipId,
                Make           = vehicle.Make,
                Model          = vehicle.Model,
                Year           = vehicle.Year,
                ParkingPlaceId = parkingPlace.ParkingPlaceId,
                GarageId       = parkingPlace.GarageId
            })
                          .Where(n => n.GarageId == iGarageId && n.IsParked == true)
                          .ToListAsync();

            // Get data i dident get in the join
            Membership  memberShip  = null;
            VehicleType vehicleType = null;

            foreach (var result in results)
            {
                // Get members first and last name
                memberShip = members.Where(m => m.MembershipId == result.MemberShipId).FirstOrDefault();
                if (memberShip != null)
                {
                    result.MemberFirstName = memberShip.FirstName;
                    result.MemberLastName  = memberShip.LastName;
                }

                // Get the vehicle type
                vehicleType = vehicleTypes.Where(v => v.VehicleTypeId == result.VehicleTypeId).FirstOrDefault();
                if (vehicleType != null)
                {
                    result.VehicleType = vehicleType.Type_Name;
                }

                result.ParkedTime = VehicleHelper.CalculateParkedTime(result.CheckInTime);
            }

            return(results);
        }