public ParkingModel GetParkingData(int Id) { ShomaRMEntities db = new ShomaRMEntities(); ParkingModel model = new ParkingModel(); var GetParkingData = db.tbl_Parking.Where(p => p.ParkingID == Id).FirstOrDefault(); if (GetParkingData != null) { model.ParkingID = GetParkingData.ParkingID; model.PropertyID = GetParkingData.PropertyID; model.ParkingName = GetParkingData.ParkingName; model.Charges = GetParkingData.Charges; model.Description = GetParkingData.Description; var GetUnitData = db.tbl_PropertyUnits.Where(p => p.UID == GetParkingData.PropertyID).FirstOrDefault(); if (GetUnitData != null) { model.UnitNo = GetUnitData.UnitNo; } var GetVehicleData = db.tbl_Vehicle.Where(p => p.ParkingID == GetParkingData.ParkingID).FirstOrDefault(); if (GetVehicleData != null) { model.OwnerName = GetVehicleData.OwnerName; model.VehicleTag = GetVehicleData.Tag; model.VehicleMake = GetVehicleData.Make; model.VehicleModel = GetVehicleData.Model; } } model.ParkingID = Id; return(model); }
public List <ParkingModel> GetUnitParkingList(int UID) { ShomaRMEntities db = new ShomaRMEntities(); List <ParkingModel> model = new List <ParkingModel>(); try { DataTable dtTable = new DataTable(); using (var cmd = db.Database.Connection.CreateCommand()) { db.Database.Connection.Open(); cmd.CommandText = "usp_Get_UnitParking"; cmd.CommandType = CommandType.StoredProcedure; DbParameter paramC = cmd.CreateParameter(); paramC.ParameterName = "UID"; paramC.Value = UID; cmd.Parameters.Add(paramC); DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter(); da.SelectCommand = cmd; da.Fill(dtTable); db.Database.Connection.Close(); } foreach (DataRow dr in dtTable.Rows) { ParkingModel usm = new ParkingModel(); usm.ParkingID = int.Parse(dr["ParkingID"].ToString()); usm.PropertyID = int.Parse(dr["PropertyID"].ToString()); usm.ParkingName = dr["ParkingName"].ToString(); usm.Charges = Convert.ToDecimal(dr["Charges"].ToString()); usm.Description = dr["Description"].ToString(); usm.Type = int.Parse(dr["Type"].ToString()); usm.Status = int.Parse(dr["Status"].ToString()); usm.AddedBy = Convert.ToInt64(dr["AddedBy"].ToString()); model.Add(usm); } db.Dispose(); return(model.ToList()); } catch (Exception ex) { db.Database.Connection.Close(); throw ex; } }
public ParkingModel GetSelectedParkingData(long PropertyId) { ShomaRMEntities db = new ShomaRMEntities(); ParkingModel model = new ParkingModel(); var ParkingInfo = db.tbl_Parking.Where(p => p.PropertyID == PropertyId).FirstOrDefault(); if (ParkingInfo != null) { model.ParkingID = ParkingInfo.ParkingID; model.PropertyID = ParkingInfo.PropertyID; model.ParkingName = ParkingInfo.ParkingName; model.Charges = ParkingInfo.Charges; model.Description = ParkingInfo.Description; } return(model); }
public string SaveUpdateParking(ParkingModel model) { string msgtxt = ""; ShomaRMEntities db = new ShomaRMEntities(); if (model.ParkingID != 0) { var ParkingInfo = db.tbl_Parking.Where(p => p.ParkingID == model.ParkingID).FirstOrDefault(); if (ParkingInfo != null) { ParkingInfo.PropertyID = model.PropertyID; ParkingInfo.ParkingName = model.ParkingName; ParkingInfo.Charges = model.Charges; ParkingInfo.Description = model.Description; db.SaveChanges(); msgtxt += "Parking information updated successfully.</br>"; var VehicleInfo = db.tbl_Vehicle.Where(p => p.ParkingID == model.ParkingID).FirstOrDefault(); if (VehicleInfo != null) { VehicleInfo.OwnerName = model.OwnerName; VehicleInfo.Tag = model.VehicleTag; VehicleInfo.Make = model.VehicleMake; VehicleInfo.Model = model.VehicleModel; db.SaveChanges(); msgtxt += "Vehicle information updated successfully.</br>"; } else { msgtxt = "Vehicle information not updated due to invalid Parking information."; } } else { msgtxt = "Parking not updated successfully."; } } db.Dispose(); return(msgtxt); }
public string SaveUpdateParkingName(ParkingModel model) { string msg = ""; ShomaRMEntities db = new ShomaRMEntities(); if (model.ParkingID != 0) { var ParkingInfo = db.tbl_Parking.Where(p => p.ParkingID == model.ParkingID).FirstOrDefault(); if (ParkingInfo != null) { ParkingInfo.ParkingName = model.ParkingName; db.SaveChanges(); msg = "Parking information updated successfully.</br>"; } else { msg = "Parking not updated successfully."; } } db.Dispose(); return(msg); }