Ejemplo n.º 1
0
 public IHttpActionResult UpdateBus(tblBu buss)
 {
     if (!ModelState.IsValid)
     {
         return(BadRequest(ModelState));
     }
     try
     {
         tblBu updBus = new tblBu();
         updBus = db.tblBus.Find("MH 04 JK 1700");
         if (updBus != null)
         {
             updBus.NoOfSeats   = buss.NoOfSeats;
             updBus.Source_     = buss.Source_;
             updBus.Destination = buss.Destination;
             updBus.ViaStop     = buss.ViaStop;
             updBus.StartTime   = buss.StartTime;
             updBus.EndTime     = buss.EndTime;
             updBus.PerSeatCost = buss.PerSeatCost;
             updBus.BusType     = buss.BusType;
             updBus.BusName     = buss.BusName;
             db.SaveChanges();
         }
         else
         {
             return(NotFound());
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(Ok(buss));
 }
        public void updateseats(string BusNo, int length)
        {
            dbNewBusEntities8 db = new dbNewBusEntities8();

            tblBu f = (from p in db.tblBus
                       where p.BusNo == BusNo
                       select p).SingleOrDefault();

            f.Availableseats = f.Availableseats - length;
            db.SaveChanges();
        }
Ejemplo n.º 3
0
 public object createbus(AddBus b)
 {
     try
     {
         dbNewBusEntities8 db = new dbNewBusEntities8();
         tblBu             bu = new tblBu();
         if (bu.BusNo == null)
         {
             bu.BusNo       = b.BusNo;
             bu.NoOfSeats   = b.NoOfSeats;
             bu.Source_     = b.Source_;
             bu.Destination = b.Destination;
             bu.ViaStop     = b.ViaStop;
             bu.StartTime   = b.StartTime;
             bu.EndTime     = b.EndTime;
             bu.PerSeatCost = b.PerSeatCost;
             bu.BusType     = b.BusType;
             bu.BusName     = b.BusName;
             db.tblBus.Add(bu);
             db.SaveChanges();
             return(new Response
             {
                 Status = "Success", Message = "SuccessFully Saved."
             });
         }
     }
     catch (Exception)
     {
         throw;
     }
     return(new Response
     {
         Status = "Error",
         Message = "Invalid Data."
     });
 }
Ejemplo n.º 4
0
        public static bool AddBusDetails(SaveBusModel model)
        {
            try
            {
                using (var item = new GMOUMISEntity())
                {
                    tblBu bs = new tblBu()
                    {
                        bus_number = model.bus_number,
                        setid      = model.setid
                    };

                    item.tblBus.Add(bs);

                    item.SaveChanges();
                    int id = bs.busid;
                    //int id = Convert.ToInt32(item.tblBus.Select(m => m.busid).FirstOrDefault());
                    tblBusInsuranceDeatil businsurancedetails = new tblBusInsuranceDeatil()
                    {
                        bus_id          = id,
                        company_name    = model.company_name,
                        company_address = model.company_address,
                        validity        = model.validity
                    };

                    item.tblBusInsuranceDeatils.Add(businsurancedetails);
                    item.SaveChanges();

                    tblBusOwnerDetail busownerDetails = new tblBusOwnerDetail()
                    {
                        bus_owner_name       = model.bus_owner_name,
                        owner_father_name    = model.owner_father_name,
                        owner_address        = model.owner_address,
                        owner_contact_number = model.owner_contact_number,
                        bus_id                 = id,
                        entry_amount           = model.entry_amount,
                        entry_reciept_number   = model.entry_reciept_number,
                        payment_date           = model.payment_date,
                        security_amount        = model.security_amount,
                        security_money_reciept = model.security_money_reciept,
                        remaining_amount       = model.remaining_amount,
                        gauranter1             = model.gauranter1,
                        gauranter1_bus         = model.gauranter1_bus,
                        gauranter2             = model.gauranter2,
                        gauranter2_bus         = model.gauranter2_bus,
                        building_fund          = model.building_fund,
                        old_bus_number         = model.old_bus_number,
                        old_bus_owner_name     = model.old_bus_owner_name,
                        previous_building_fund = model.previous_building_fund,
                        emi = model.emi
                    };
                    item.tblBusOwnerDetails.Add(busownerDetails);
                    tblBusDetail busdetails = new tblBusDetail()
                    {
                        bus_id               = id,
                        bus_number           = model.bus_number,
                        bus_operating_center = model.bus_operating_center,
                        chesis_number        = model.chesis_number,
                        engine_number        = model.engine_number,
                        fitness              = model.fitness,
                        last_modified_date   = DateTime.Now,
                        registration_date    = model.registration_date,
                        permit_number        = model.permit_number,
                        model                   = model.model,
                        seats                   = model.seats,
                        road_tax                = model.road_tax,
                        isDeleted               = false,
                        last_modified_by        = "Admin",
                        bus_registration_type   = model.bus_registration_type,
                        bus_registration_number = model.bus_registration_number
                    };
                    item.tblBusDetails.Add(busdetails);
                    item.SaveChanges();
                }
                return(true);
            }

            catch (Exception ex)
            {
                string err = ex.Message;
                return(false);
            }
        }