public ActionResult CurrentCarServiceDetail(CurrentCarServiceDetailModel model) { // Get Car Information var CarServiceDetail = db.Garage_CarDaySetting.Where(q => q.Id == model.CurrentCarServiceId && q.EntityTypeKey == (int)EntityTypeKey.Car ).SingleOrDefault(); if (CarServiceDetail == null) { return(RedirectToAction("Index")); } CarServiceDetail.Comment = model.Comment; db.SaveChanges(); return(RedirectToAction("CurrentCarServiceDetail", "CrewLeader", new { id = model.CurrentCarServiceId })); }
public ActionResult CurrentCarServiceEndJob(CurrentCarServiceDetailModel model) { // Get Car Information var CarServiceDetail = db.Garage_CarDaySetting.Where(q => q.Id == model.CurrentCarServiceId && q.EntityTypeKey == (int)EntityTypeKey.Car ).SingleOrDefault(); if (CarServiceDetail == null) { return(RedirectToAction("Index")); } CarServiceDetail.ServiceStatusId = (int)ServiceStatus.Complated; CarServiceDetail.EndTime = DateTime.Now; db.SaveChanges(); string ServiceName = string.Empty; int carId = Convert.ToInt32(CarServiceDetail.EntityTypeValue); var aspCar = db.CarUsers.Where(c => c.CarId == carId).SingleOrDefault(); if (aspCar != null) { // Set Last and Next service date userPackage var activeUserPackage = aspCar.UserPackages.Where(u => u.PaymentRecieved == true && u.IsActive == true).FirstOrDefault(); if (activeUserPackage != null) { activeUserPackage.LastServiceDate = activeUserPackage.NextServiceDate; activeUserPackage.NextServiceDate = Convert.ToDateTime(activeUserPackage.NextServiceDate).AddDays(activeUserPackage.SubscriptionTypeId * 7); } model.CarService = new CarServices() { ServiceDayId = CarServiceDetail.Id, CarId = aspCar.CarId, CarDisplayName = aspCar.DisplayName, Color = aspCar.Color, LicenseNumber = aspCar.LicenseNumber, serviceStatus = (ServiceStatus)CarServiceDetail.ServiceStatusId, }; // Get Car Services Information model.CarService.SelectServices = new List <CarServices.SelectService>(); var pCarId = new SqlParameter(); pCarId.ParameterName = "CarId"; pCarId.Value = aspCar.CarId; pCarId.DbType = DbType.Int32; var servicesList = db.Database.SqlQuery <GreenPro.Data.Service>( "EXEC dbo.GetServicesByCarId @CarId", pCarId ).ToList(); if (servicesList.Count > 0) { ServiceName += "<ul>"; foreach (var service in servicesList) { CarServices.SelectService seviceModel = new CarServices.SelectService(); seviceModel.ServiceName = service.Service_Name; model.CarService.SelectServices.Add(seviceModel); ServiceName += "<li>" + service.Service_Name + "</li>"; } ServiceName += "</ul>"; } } var userInfo = aspCar.AspNetUser; _workflowMessageService.SendCarServiceCompletionNotificationtoCustomer(userInfo.UserName, userInfo.Email, ServiceName); return(RedirectToAction("CurrentCarServiceDetail", "CrewLeader", new { id = model.CurrentCarServiceId })); }
public ActionResult CurrentCarServiceDetail(int Id) { CurrentCarServiceDetailModel model = new CurrentCarServiceDetailModel(); // Get Car Information var CarServiceDetail = db.Garage_CarDaySetting.Where(q => q.Id == Id && q.EntityTypeKey == (int)EntityTypeKey.Car ).SingleOrDefault(); if (CarServiceDetail == null) { return(RedirectToAction("Index")); } model.CurrentCarServiceId = Id; int carId = Convert.ToInt32(CarServiceDetail.EntityTypeValue); var aspCar = db.CarUsers.Where(c => c.CarId == carId).SingleOrDefault(); if (aspCar != null) { model.CarService = new CarServices() { ServiceDayId = CarServiceDetail.Id, CarId = aspCar.CarId, CarDisplayName = aspCar.DisplayName, Make = aspCar.Make, PurchaseYear = aspCar.PurchaseYear, Color = aspCar.Color, LicenseNumber = aspCar.LicenseNumber, serviceStatus = (ServiceStatus)CarServiceDetail.ServiceStatusId, //ServiceStatusId = CarServiceDetail.ServiceStatusId, }; model.ServiceStatusId = CarServiceDetail.ServiceStatusId; if (CarServiceDetail.StartTime.HasValue) { model.StartDateTime = CarServiceDetail.StartTime; } if (CarServiceDetail.EndTime.HasValue) { model.EndDateTime = CarServiceDetail.EndTime; } model.Comment = CarServiceDetail.Comment; // Get Car Services Information model.CarService.SelectServices = new List <CarServices.SelectService>(); var pCarId = new SqlParameter(); pCarId.ParameterName = "CarId"; pCarId.Value = aspCar.CarId; pCarId.DbType = DbType.Int32; var servicesList = db.Database.SqlQuery <GreenPro.Data.Service>( "EXEC dbo.GetServicesByCarId @CarId", pCarId ).ToList(); if (servicesList.Count > 0) { foreach (var service in servicesList) { CarServices.SelectService seviceModel = new CarServices.SelectService(); seviceModel.ServiceName = service.Service_Name; model.CarService.SelectServices.Add(seviceModel); } } } model.AvailableServiceStatus = ListHelper.GetServiceStatusList(); return(View(model)); }