public static bool Update(CustomerViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstCustomer ctm = new MstCustomer(); ctm.CustomerId = model.CustomerId; ctm.CustomerName = model.CustomerName; ctm.OrganizationName = model.OrganizationName; ctm.CustomerAddress = model.CustomerAddress; ctm.OrganizationAddress = model.OrganizationAddress; ctm.IdNumber = model.IdNumber; ctm.CustomerPhone = model.CustomerPhone; ctm.OrganizationPhone = model.OrganizationPhone; ctm.OrganizationEmail = model.OrganizationEmail; ctm.IsActive = model.IsActive; db.MstCustomers.Add(ctm); db.SaveChanges(); } else { MstCustomer ctm = db.MstCustomers.Where(o => o.Id == model.Id).FirstOrDefault(); if (ctm != null) { ctm.CustomerId = model.CustomerId; ctm.CustomerName = model.CustomerName; ctm.OrganizationName = model.OrganizationName; ctm.CustomerAddress = model.CustomerAddress; ctm.OrganizationAddress = model.OrganizationAddress; ctm.IdNumber = model.IdNumber; ctm.CustomerPhone = model.CustomerPhone; ctm.OrganizationPhone = model.OrganizationPhone; ctm.OrganizationEmail = model.OrganizationEmail; ctm.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception Ex) { Message = Ex.Message; result = false; } return(result); }
public static bool Update(CrewViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstCrew crw = new MstCrew(); crw.CrewId = model.CrewId; crw.CrewName = model.CrewName; crw.DrivingLicenseNumber = model.DrivingLicenseNumber; crw.Address = model.Address; crw.PlaceOfBirth = model.PlaceOfBirth; crw.DateOfBirth = model.DateOfBirth; crw.Gender = model.Gender; crw.Role = model.Role; crw.IsActive = model.IsActive; db.MstCrews.Add(crw); db.SaveChanges(); } else { MstCrew crw = db.MstCrews.Where(o => o.Id == model.Id).FirstOrDefault(); if (crw != null) { crw.CrewId = model.CrewId; crw.CrewName = model.CrewName; crw.DrivingLicenseNumber = model.DrivingLicenseNumber; crw.Address = model.Address; crw.PlaceOfBirth = model.PlaceOfBirth; crw.DateOfBirth = model.DateOfBirth; crw.Gender = model.Gender; crw.Role = model.Role; crw.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception Ex) { Message = Ex.Message; result = false; } return(result); }
public static bool Update(TypeBusViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstTypeBu typebus = new MstTypeBu(); typebus.MerkId = model.MerkId; typebus.TypeId = model.TypeId; typebus.Description = model.Description; typebus.IsActive = model.IsActive; typebus.CreatedBy = model.CreatedBy; typebus.Created = model.Created; typebus.ModifiedBy = model.ModifiedBy; typebus.Modified = model.Modified; db.MstTypeBus.Add(typebus); db.SaveChanges(); } else { MstTypeBu typebus = db.MstTypeBus.Where(o => o.Id == model.Id).FirstOrDefault(); if (typebus != null) { typebus.MerkId = model.MerkId; typebus.TypeId = model.TypeId; typebus.Description = model.Description; typebus.IsActive = model.IsActive; typebus.CreatedBy = model.CreatedBy; typebus.Created = model.Created; typebus.ModifiedBy = model.ModifiedBy; typebus.Modified = model.Modified; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(PartViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstPart part = new MstPart(); part.PartId = model.PartId; part.Description = model.Description; part.Price = model.Price; part.IsActive = model.IsActive; part.CreatedBy = model.CreatedBy; part.Created = model.Created; part.ModifiedBy = model.ModifiedBy; part.Modified = model.Modified; db.MstParts.Add(part); db.SaveChanges(); } else { MstPart part = db.MstParts.Where(o => o.Id == model.Id).FirstOrDefault(); if (part != null) { part.PartId = model.PartId; part.Description = model.Description; part.Price = model.Price; part.IsActive = model.IsActive; part.CreatedBy = model.CreatedBy; part.Created = model.Created; part.ModifiedBy = model.ModifiedBy; part.Modified = model.Modified; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(ServiceViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstService service = new MstService(); service.ServiceId = model.ServiceId; service.Description = model.Description; service.IsActive = model.IsActive; service.CreatedBy = model.CreatedBy; service.Created = model.Created; service.ModifiedBy = model.ModifiedBy; service.Modified = model.Modified; db.MstServices.Add(service); db.SaveChanges(); } else { MstService service = db.MstServices.Where(o => o.Id == model.Id).FirstOrDefault(); if (service != null) { service.ServiceId = model.ServiceId; service.Description = model.Description; service.IsActive = model.IsActive; service.CreatedBy = model.CreatedBy; service.Created = model.Created; service.ModifiedBy = model.ModifiedBy; service.Modified = model.Modified; db.SaveChanges(); } } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Update(FleetViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstFleet flt = new MstFleet(); flt.FleetId = model.FleetId; flt.TypeId = model.TypeId; flt.LicenseNumber = model.LicenseNumber; flt.KaroseriId = model.KaroseriId; flt.SeatCapacity = model.SeatCapacity; flt.IsActive = model.IsActive; db.MstFleets.Add(flt); db.SaveChanges(); } else { MstFleet flt = db.MstFleets.Where(o => o.Id == model.Id).FirstOrDefault(); if (flt != null) { flt.FleetId = model.FleetId; flt.TypeId = model.TypeId; flt.LicenseNumber = model.LicenseNumber; flt.KaroseriId = model.KaroseriId; flt.SeatCapacity = model.SeatCapacity; flt.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception Ex) { Message = Ex.Message; result = false; } return(result); }
public static bool Update(KaroseriViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { if (model.Id == 0) { MstKaroseri kar = new MstKaroseri(); kar.KaroseriId = model.KaroseriId; kar.Description = model.Description; kar.IsActive = model.IsActive; db.MstKaroseris.Add(kar); db.SaveChanges(); } else { MstKaroseri kar = db.MstKaroseris.Where(o => o.Id == model.Id).FirstOrDefault(); if (kar != null) { kar.KaroseriId = model.KaroseriId; kar.Description = model.Description; kar.IsActive = model.IsActive; db.SaveChanges(); } } } } catch (Exception Ex) { Message = Ex.Message; result = false; } return(result); }
public static bool Update(MaintenanceHeaderViewModel model) { bool result = true; try { using (var db = new FleetManagementContext()) { TrxMaintenanceHeader mh = new TrxMaintenanceHeader(); mh.Id = 1; mh.MaintenanceId = model.MaintenanceId; mh.MaintenanceDate = model.MaintenanceDate; mh.FleetId = model.FleetId; mh.MaintenanceKm = model.MaintenanceKm; mh.TotalPrice = model.TotalPrice; db.TrxMaintenanceHeaders.Add(mh); foreach (var item in model.MaintenanceDetails) { TrxMaintenanceDetail md = new TrxMaintenanceDetail(); md.MaintenanceId = mh.MaintenanceId; md.MechanicId = item.MechanicId; md.ServiceId = item.ServiceId; md.PartId = item.PartId; md.PartQuantity = item.PartQuantity; md.SubTotalPrice = item.SubTotalPrice; db.TrxMaintenanceDetails.Add(md); } db.SaveChanges(); } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }
public static bool Delete(int id) { bool result = true; try { using (var db = new FleetManagementContext()) { MstKaroseri kar = db.MstKaroseris.Where(o => o.Id == id).FirstOrDefault(); if (kar != null) { db.MstKaroseris.Remove(kar); db.SaveChanges(); } } } catch (Exception Ex) { Message = Ex.Message; result = false; } return(result); }
public static bool Delete(int id) { bool result = true; try { using (var db = new FleetManagementContext()) { MstTypeBu typebus = db.MstTypeBus.Where(o => o.Id == o.Id).FirstOrDefault(); if (typebus != null) { db.MstTypeBus.Remove(typebus); db.SaveChanges(); } } } catch (Exception ex) { Message = ex.Message; result = false; } return(result); }