Exemplo n.º 1
0
        public int Update(TripModel model)
        {
            Mapper.CreateMap <TripModel, TripMaster>();
            TripMaster objInsu = dbContext.TripMasters.SingleOrDefault(m => m.TID == model.TID);

            objInsu = Mapper.Map(model, objInsu);
            return(dbContext.SaveChanges());
        }
Exemplo n.º 2
0
        public TripModel getByID(int?id)
        {
            Mapper.CreateMap <TripMaster, TripModel>();
            TripMaster objDep     = dbContext.TripMasters.SingleOrDefault(m => m.TID == id);
            TripModel  objDepItem = Mapper.Map <TripModel>(objDep);

            return(objDepItem);
        }
Exemplo n.º 3
0
        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());
        }