public bool IsGarageInfoEdited(GarageInfo entity) { using (var db = new SCMSEntities()) { clearSession(); var existing = db.GarageInfoes.FirstOrDefault(p => p.Id == entity.Id); db.Entry(existing).CurrentValues.SetValues(entity); return db.SaveChanges() > 0 ? true : false; } }
/// <summary> /// changing vehicle status. /// </summary> public static void ChangeVehicleStatus() { Console.WriteLine("Please enter Vehicle license number to change it's status:"); string vehicleLicenseNumber = Console.ReadLine(); Console.WriteLine("Please enter Vehicle new status: 1.Currently repairing 2.Repaired 3.Paid up "); string vehicleNewStatus = Console.ReadLine(); GarageInfo.eCurrentVehicleState newVehicleState = (GarageInfo.eCurrentVehicleState) int.Parse(vehicleNewStatus); GarageInfo.ChangeVehicleStatus(vehicleLicenseNumber, newVehicleState); }
public bool IsGarageInfoSaved(GarageInfo Entity, IEnumerable<Guid> ServicedItems) { using (var db = new SCMSEntities()) { clearSession(); if (Entity.ReasonType == "Service") Entity.IfServiceNextMilleage = Entity.IfServiceCurrentMilleage + db.CheckListCategories.FirstOrDefault(p => p.Id == Entity.ChecKListCatId).Name; db.GarageInfoes.Add(Entity); if (ServicedItems != null && ServicedItems.Count() > 0) foreach (var item in ServicedItems) db.GarageSeviceChecks.Add(new GarageSeviceCheck() { ServiceCheckId = item, Id = Guid.NewGuid(), GarageInfoId = Entity.Id, ServiceId = Entity.ChecKListCatId.Value, IssueDate = DateTime.Now }); return db.SaveChanges() > 0 ? true : false; } }
/// <summary> /// adding vehicle to treatment status. /// </summary> /// <param name="i_Vehicle"> vehicle.</param> public static void AddVehicleToTreatment(Vehicle i_Vehicle) { const int phoneNumberLength = 10; Console.WriteLine("Please add owner name: "); string ownerName = Console.ReadLine(); Console.WriteLine("Please add owner phone number: "); string ownerNumber = Console.ReadLine(); if (ownerNumber.Length != phoneNumberLength) { throw new ArgumentException(); } GarageInfo vehicleToTreatment = new GarageInfo(i_Vehicle, ownerNumber, ownerName); vehicleToTreatment.InsertVehicleToGarageForTreatment(i_Vehicle.LicenseNumber); }
public ActionResult SaveNewGarageInfo(GarageInfo entitymodel) { entitymodel.Id = Guid.NewGuid(); entitymodel.IssueDate = DateTime.Now; if (entitymodel.ReasonType != "Service") { entitymodel.IfServiceNextMilleage = entitymodel.IfServiceCurrentMilleage; } if (entitymodel.ReasonType == "Maintenance") { entitymodel.ReasonType += " " + entitymodel.MaintenaceType; } if (fleetservice.IsGarageInfoSaved(entitymodel, UserSession.CurrentSession.ServiceItems)) { UserSession.CurrentSession.ServiceItems = null; } return(LoadFleetDetails(entitymodel.FleetId)); }
public ActionResult EditGarageInfo(GarageInfo entitymodel) { entitymodel.Id = new Guid(entitymodel.SavedId); fleetservice.IsGarageInfoEdited(entitymodel); return(LoadFleetDetails(entitymodel.FleetId)); }