public async Task <string> SaveHotelAsync(HotelSaveModel model) { try { ConvertListToDT objDT = new ConvertListToDT(); DataTable typeDt = new DataTable(); var parHotelID = new SqlParameter("@HotelID", model.HotelID); var parDestID = new SqlParameter("@DestinationID", model.DestinationID); var parHotelName = new SqlParameter("@HotelName", model.HotelName); var parHotelAddress = new SqlParameter("@HotelAddress", model.HotelAddress); var parHotelContact = new SqlParameter("@HotelContact", model.HotelContact); var parHotelEmail = new SqlParameter("@HotelEmail", model.HotelEmail ?? ""); List <IDModel> tyepList = model.HotelTypes.Select(x => new IDModel() { ID = Convert.ToInt64(x) }).ToList(); typeDt = objDT.ConvertIEnumerableToDataTable(tyepList); var parSubDT = new SqlParameter("@HotelTypeTable", typeDt); parSubDT.SqlDbType = SqlDbType.Structured; parSubDT.TypeName = "dbo.IDType"; return(await db.Database.SqlQuery <string>("udspMstHotelSave @HotelID, @DestinationID, @HotelName, @HotelAddress, @HotelContact, @HotelEmail, @HotelTypeTable", parHotelID, parDestID, parHotelName, parHotelAddress, parHotelContact, parHotelEmail, parSubDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <GenTourPackageVM> SearchGenTourPackageListAsync(GenSearchModel search) { GenTourPackageVM model = new GenTourPackageVM(); ConvertListToDT objList = new ConvertListToDT(); DataTable subdt = new DataTable(); try { //Converting subject list to datatable if record is present else send empty datatable if (search.TourType != null) { List <IDModel> villList = search.TourType.Select(x => new IDModel() { ID = Convert.ToInt64(x) }).ToList(); subdt = objList.ConvertIEnumerableToDataTable(villList); } else { if (subdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "ID"; subdt.Columns.Add(col); } } var parSubDT = new SqlParameter("@TourTypeTable", subdt); parSubDT.SqlDbType = SqlDbType.Structured; parSubDT.TypeName = "dbo.IDType"; var parStart = new SqlParameter("@Start", (search.PageNo - 1) * search.PageSize); var parEnd = new SqlParameter("@PageSize", search.PageSize); var parWhere = new SqlParameter("@Where", DBNull.Value); if (!(search.Where == null || search.Where == "")) { parWhere.Value = search.Where; } // setting stored procedure OUTPUT value // This return total number of rows, and avoid two database call for data and total number of rows var spOutput = new SqlParameter { ParameterName = "@TotalCount", SqlDbType = System.Data.SqlDbType.BigInt, Direction = System.Data.ParameterDirection.Output }; model.PackageList = await db.Database.SqlQuery <GenTourPackageView>("udspGenTourPackageSearch @Start, @PageSize,@Where, @TourTypeTable, @TotalCount out", parStart, parEnd, parWhere, parSubDT, spOutput).ToListAsync(); model.TotalRecords = int.Parse(spOutput.Value.ToString()); return(model); } catch (Exception ex) { throw ex; } }
public async Task <string> SaveClientEnqActAsync(IEnumerable <utblClientEnquiryActivitie> model) { try { var parEnquiryCode = new SqlParameter("@enquirycode", model.ElementAt(0).EnquiryCode); ConvertListToDT objList = new ConvertListToDT(); DataTable actdt = new DataTable(); //Converting subject list to datatable if record is present else send empty datatable if (model != null) { actdt = objList.ConvertIEnumerableToDataTable(model); } else { if (actdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "ClientActivityID"; actdt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "EnquiryCode"; actdt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "RefPackageID"; actdt.Columns.Add(col2); DataColumn col3 = new DataColumn(); col3.ColumnName = "ActivityID"; actdt.Columns.Add(col3); } } var parActDT = new SqlParameter("@ClientActivityTable", actdt); parActDT.SqlDbType = SqlDbType.Structured; parActDT.TypeName = "dbo.ClientActivityType"; return(await objDB.Database.SqlQuery <string>("udspClientEnquiryActivitySave @enquirycode, @CLientActivityTable", parEnquiryCode, parActDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <string> SaveItinerariesAsync(IEnumerable <utblTourPackageItinerary> model) { try { var parPackID = new SqlParameter("@PackageID", model.ElementAt(0).PackageID); ConvertListToDT objDT = new ConvertListToDT(); DataTable dt = objDT.ConvertIEnumerableToDataTable(model); var parSubDT = new SqlParameter("@ItineraryTable", dt); parSubDT.SqlDbType = SqlDbType.Structured; parSubDT.TypeName = "dbo.PackageItineraryType"; return(await db.Database.SqlQuery <string>("udspTourPackageItinerarySave @PackageID, @ItineraryTable", parPackID, parSubDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <string> SaveItinerariesAsync(IEnumerable <utblClientEnquiryItinerarie> model) { try { var parEnquiryCode = new SqlParameter("@enqirycode", model.ElementAt(0).EnquiryCode); ConvertListToDT objDT = new ConvertListToDT(); DataTable dt = objDT.ConvertIEnumerableToDataTable(model); var parSubDT = new SqlParameter("@ClientItineraryTable", dt); parSubDT.SqlDbType = SqlDbType.Structured; parSubDT.TypeName = "dbo.ClientItineraryType"; return(await objDB.Database.SqlQuery <string>("udspClientEnquiryItinerarySave @enqirycode, @ClientItineraryTable", parEnquiryCode, parSubDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <string> SavePackageOfferAsync(SavePackageOffer model) { try { ConvertListToDT objDT = new ConvertListToDT(); DataTable typeDt = new DataTable(); var parPOffID = new SqlParameter("@PackageOfferID", model.PackageOffer.PackageOfferID); //var parPacID = new SqlParameter("@PackageID", DBNull.Value); //if (model.PackageID != null) // parPacID = new SqlParameter("@PackageID", model.PackageID); var parOfferDiscount = new SqlParameter("@OfferDiscount", model.PackageOffer.OfferDiscount); var parOfferDesc = new SqlParameter("@OfferDesc", model.PackageOffer.OfferDesc); //var parPOffer = new SqlParameter("@OfferPercent", model.PackageOffer.OfferPercent); var parOfferImgPath = new SqlParameter("@OfferImagePath", model.PackageOffer.OfferImagePath); var parStart = new SqlParameter("@StartDate", model.PackageOffer.StartDate); var parEnd = new SqlParameter("@EndDate", model.PackageOffer.EndDate); List <IDModel> tyepList = model.PackageID.Select(x => new IDModel() { ID = Convert.ToInt64(x) }).ToList(); typeDt = objDT.ConvertIEnumerableToDataTable(tyepList); var parSubDT = new SqlParameter("@PackageOfferTable", typeDt); parSubDT.SqlDbType = SqlDbType.Structured; parSubDT.TypeName = "dbo.IDType"; return(await db.Database.SqlQuery <string>("udspPackageOfferSave @PackageOfferID,@OfferDiscount, @OfferDesc, @OfferImagePath, @StartDate, @EndDate,@PackageOfferTable", parPOffID, parOfferDiscount, parOfferDesc, parOfferImgPath, parStart, parEnd, parSubDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <string> SavePackageExcTermsAsync(PackageExcTermSaveModel model) { try { var parPackID = new SqlParameter("@PackageID", model.PackageID); ConvertListToDT objList = new ConvertListToDT(); DataTable excdt = new DataTable(); DataTable termdt = new DataTable(); DataTable candt = new DataTable(); //Converting subject list to datatable if record is present else send empty datatable if (model.Exclusions != null) { excdt = objList.ConvertIEnumerableToDataTable(model.Exclusions); } else { if (excdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "PackageExclusionID"; excdt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "PackageID"; excdt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "ExclusionID"; excdt.Columns.Add(col2); } } var parExDT = new SqlParameter("@ExclusionTable", excdt); parExDT.SqlDbType = SqlDbType.Structured; parExDT.TypeName = "dbo.ExclusionType"; if (model.Terms != null) { termdt = objList.ConvertIEnumerableToDataTable(model.Terms); } else { if (termdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "PackageTermsID"; termdt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "PackageID"; termdt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "TermID"; termdt.Columns.Add(col2); } } var parTermDT = new SqlParameter("@TermTable", termdt); parTermDT.SqlDbType = SqlDbType.Structured; parTermDT.TypeName = "dbo.TermType"; if (model.Cancellations != null) { candt = objList.ConvertIEnumerableToDataTable(model.Cancellations); } else { if (candt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "PackageCancID"; candt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "PackageID"; candt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "CancellationID"; candt.Columns.Add(col2); } } var parCanDT = new SqlParameter("@CancellationTable", candt); parCanDT.SqlDbType = SqlDbType.Structured; parCanDT.TypeName = "dbo.CancellationType"; return(await db.Database.SqlQuery <string>("udspTourPackageExclusionTermSave @PackageID, @ExclusionTable, @TermTable, @CancellationTable", parPackID, parExDT, parTermDT, parCanDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }
public async Task <string> SavePackageActIncAsync(PackageActIncSaveModel model) { try { var parPackID = new SqlParameter("@PackageID", model.PackageID); ConvertListToDT objList = new ConvertListToDT(); DataTable actdt = new DataTable(); DataTable incdt = new DataTable(); //Converting subject list to datatable if record is present else send empty datatable if (model.Activities != null) { actdt = objList.ConvertIEnumerableToDataTable(model.Activities); } else { if (actdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "PackageActivityID"; actdt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "PackageID"; actdt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "ActivityID"; actdt.Columns.Add(col2); DataColumn col3 = new DataColumn(); col3.ColumnName = "ActivityFare"; actdt.Columns.Add(col3); } } var parActDT = new SqlParameter("@ActivityTable", actdt); parActDT.SqlDbType = SqlDbType.Structured; parActDT.TypeName = "dbo.ActivityType"; if (model.Inclusions != null) { incdt = objList.ConvertIEnumerableToDataTable(model.Inclusions); } else { if (incdt.Columns.Count == 0) { DataColumn col = new DataColumn(); col.ColumnName = "PackageInclusionID"; incdt.Columns.Add(col); DataColumn col1 = new DataColumn(); col1.ColumnName = "PackageID"; incdt.Columns.Add(col1); DataColumn col2 = new DataColumn(); col2.ColumnName = "InclusionID"; incdt.Columns.Add(col2); DataColumn col3 = new DataColumn(); col3.ColumnName = "InclusionFare"; incdt.Columns.Add(col3); } } var parIncDT = new SqlParameter("@InclusionTable", incdt); parIncDT.SqlDbType = SqlDbType.Structured; parIncDT.TypeName = "dbo.InclusionType"; return(await db.Database.SqlQuery <string>("udspTourPackageActivityInclusionSave @PackageID, @ActivityTable, @InclusionTable", parPackID, parActDT, parIncDT).FirstOrDefaultAsync()); } catch (Exception ex) { return("Error: " + ex.Message); } }