Example #1
0
        public IEnumerable <CategoryModel> getVehicleLoadCategoryList(int UserId, FindSpaceViewModel searchVM)
        {
            var categoryList = (from U in dbContext.Users
                                join VC in dbContext.LoadownerCategories on U.UserId equals VC.UserId
                                join OC in dbContext.OverloadCategories on VC.CategoryId equals OC.CategoryId
                                join LS in dbContext.LoadSpaces on OC.LoadSpaceId equals LS.LoadSpaceId
                                //where U.UserId == UserId
                                where U.UserType == "M"

                                select new CategoryModel
            {
                CategoryId = OC.CategoryId,
                Name = OC.Name,
                Image = OC.Image == null ? "/Images/CategoryImage.jpg" : "/Images/Category/" + OC.Image,
                UserId = U.UserId,
                CreatedDate = (DateTime)OC.CreatedDate,
                ChannelNo = OC.ChannelNo,
                Price = (decimal)OC.Price,
                IsFreeChannel = (bool)OC.IsFree,
                FirstName = U.FirstName,
                LastName = U.LastName,
                ProfileImage = U.ProfilePicture == null ? "/Images/nopic.png" : "/Images/ProfilePicture/" + U.ProfilePicture,
                IsChannelAvailable = OC.IsAvailable == null ? true : (bool)OC.IsAvailable,



                Description = OC.Description,
                PickupLocation = OC.PickupLocation,
                PickupDate = (DateTime)OC.PickupDate,
                DropOffLocation = OC.DropOffLocation,
                DropOffDate = (DateTime)OC.DropOffDate,

                LoadSpaceTitle = LS.LoadSpaceTitle
            }).OrderByDescending(x => x.CategoryId).ToList();

            if (searchVM.from != null)
            {
                categoryList = categoryList.Where(c => c.PickupLocation.Contains(searchVM.from)).ToList();
            }
            if (searchVM.to != null)
            {
                categoryList = categoryList.Where(c => c.DropOffLocation.Contains(searchVM.to)).ToList();
            }
            if (searchVM.date != null)
            {
                categoryList = categoryList.Where(c => c.PickupDate == searchVM.date).ToList();
            }
            return(categoryList);
        }
Example #2
0
 public ActionResult Index(FindSpaceViewModel searchVM)
 {
     try
     {
         if (searchVM == null)
         {
             return(RedirectToAction("Index", "FindSpace"));
         }
         var model = service.getVehicleLoadCategoryList(sUser.UserId, searchVM);
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "FindSpace"));
     }
 }
 public ActionResult Index(FindSpaceViewModel searchVM)
 {
     try
     {
         if (sUser.UserType == "A")
         {
             return(RedirectToAction("Index", "Vehicleowner", searchVM));
         }
         if (searchVM == null)
         {
             return(RedirectToAction("Index", "FindSpace"));
         }
         var model = service.getLoadownerCategoryListBySearch(searchVM);
         return(View(model));
     }
     catch (Exception ex)
     {
         return(RedirectToAction("Index", "FindSpace"));
     }
 }