public int updateTripVhcl(int tvid, int totalvhcl, int?vtid) { TripVehicle objTVhcl = new TripVehicle(); objTVhcl = dbContext.TripVehicles.SingleOrDefault(m => m.TVID == tvid); objTVhcl.TotalVehicle = totalvhcl; objTVhcl.VTID = vtid; return(dbContext.SaveChanges()); }
public int InsertTrip(TripModel model) { Mapper.CreateMap <TripModel, TripMaster>(); TripMaster objStockItem = Mapper.Map <TripMaster>(model); dbContext.TripMasters.Add(objStockItem); dbContext.SaveChanges(); int tid = dbContext.TripMasters.Max(m => m.TID); if (model.VTypeModel.VTID != null) { model.VTypeModel.TID = tid; //model.VTypeModel.VTID = model.VTID; //model.VTypeModel.TotalVehicle = model.TotalVehicle; Mapper.CreateMap <TripVehicleModel, TripVehicle>(); TripVehicle objPetrol = Mapper.Map <TripVehicle>(model.VTypeModel); dbContext.TripVehicles.Add(objPetrol); dbContext.SaveChanges(); } if (model.VTypeModel.VTID != null || model.VTypeModel.VTID == null) { model.VTypeModel.TID = tid; model.VTypeModel.VTID = model.VTypeModel.VTID1; model.VTypeModel.TotalVehicle = model.VTypeModel.TotalVehicle1; Mapper.CreateMap <TripVehicleModel, TripVehicle>(); TripVehicle objPetrol = Mapper.Map <TripVehicle>(model.VTypeModel); dbContext.TripVehicles.Add(objPetrol); dbContext.SaveChanges(); } if (model.VTypeModel.VTID != null || model.VTypeModel.VTID == null) { model.VTypeModel.TID = tid; model.VTypeModel.VTID = model.VTypeModel.VTID2; model.VTypeModel.TotalVehicle = model.VTypeModel.TotalVehicle2; Mapper.CreateMap <TripVehicleModel, TripVehicle>(); TripVehicle objPetrol = Mapper.Map <TripVehicle>(model.VTypeModel); dbContext.TripVehicles.Add(objPetrol); dbContext.SaveChanges(); } if (model.VTypeModel.VTID != null || model.VTypeModel.VTID == null) { model.VTypeModel.TID = tid; model.VTypeModel.VTID = model.VTypeModel.VTID3; model.VTypeModel.TotalVehicle = model.VTypeModel.TotalVehicle3; Mapper.CreateMap <TripVehicleModel, TripVehicle>(); TripVehicle objPetrol = Mapper.Map <TripVehicle>(model.VTypeModel); dbContext.TripVehicles.Add(objPetrol); dbContext.SaveChanges(); } return(dbContext.SaveChanges()); }