public bool AddUnitSize(UnitSizes T) { try { dc.UnitSizes.Add(T); dc.SaveChanges(); return(true); } catch { return(false); } }
public bool EditUnitSize(UnitSizes T) { try { var data = dc.UnitSizes.Where(o => o.Id == T.Id).FirstOrDefault(); data.Description = T.Description; dc.SaveChanges(); return(true); } catch { return(false); } }
public List <Vacation> getProcessedEntry(string[] entry, string supplierName, int adminFee, int lineCount) { // Build Error Message here List <Vacation> result = new List <Vacation>(); Vacation tempVacation; Resort tempResort = getResortFromString(entry[2]); UnitSizes tempUnitSizes = getUnitSizesFromString(entry[8]); Supplier tempSupplier = GetSupplierFromString(supplierName); if (tempResort == null) { errorLines.Add("At row " + Convert.ToString(lineCount) + " Resort name have a spelling mistake."); } if (tempUnitSizes == null) { errorLines.Add("At row " + Convert.ToString(lineCount) + " Unit Size name have a spelling mistake."); } if (tempResort == null || tempUnitSizes == null || tempSupplier == null) { return(null); } try { // Full week if (Convert.ToInt32(entry[10]) != 0) { tempVacation = new Vacation(); tempVacation.ResortId = tempResort.Id; tempVacation.UnitSizeId = tempUnitSizes.Id; tempVacation.SupplierId = tempSupplier.Id; tempVacation.Arrival = Convert.ToDateTime(entry[5]); tempVacation.Nights = (Convert.ToDateTime(entry[6]) - Convert.ToDateTime(entry[5])).Days; tempVacation.Price2Pay = Convert.ToInt32(entry[14]); tempVacation.BuyingPrice = CalculateBuyingPriceFW(Convert.ToDouble(entry[10])); tempVacation.AdminFee = adminFee; tempVacation.Sold = false; tempVacation.Hold = false; result.Add(tempVacation); } // Weekend if (Convert.ToInt32(entry[11]) != 0) { tempVacation = new Vacation(); tempVacation.ResortId = tempResort.Id; tempVacation.UnitSizeId = tempUnitSizes.Id; tempVacation.SupplierId = tempSupplier.Id; tempVacation.Arrival = getArrivalDateWeekend(entry[5]); tempVacation.Nights = 3; tempVacation.Price2Pay = Convert.ToInt32(entry[15]); tempVacation.BuyingPrice = CalculateBuyingPriceWE(Convert.ToDouble(entry[11])); tempVacation.AdminFee = adminFee; tempVacation.Sold = false; tempVacation.Hold = false; result.Add(tempVacation); } // Mid Week if (Convert.ToInt32(entry[12]) != 0) { tempVacation = new Vacation(); tempVacation.ResortId = tempResort.Id; tempVacation.UnitSizeId = tempUnitSizes.Id; tempVacation.SupplierId = tempSupplier.Id; tempVacation.Arrival = getArrivalDateMidWeek(entry[5]); tempVacation.Nights = 4; tempVacation.Price2Pay = Convert.ToInt32(entry[16]); tempVacation.BuyingPrice = CalculateBuyingPriceMW(Convert.ToDouble(entry[12])); tempVacation.AdminFee = adminFee; tempVacation.Sold = false; tempVacation.Hold = false; result.Add(tempVacation); } if (result.Count == 0) { return(null); } return(result); } catch (Exception e) { errorLines.Add("At row " + Convert.ToString(lineCount) + " there is a unknown ERROR, please check each column in that row."); return(null); } }
public IActionResult editUnitSizes([FromBody] UnitSizes T) { return(Ok(unitSizeRepository.EditUnitSize(T))); }
public async Task EmailToAdminAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize) { var message = new TemplatedPostmarkMessage { //To = "*****@*****.**", To = "*****@*****.**", From = EmailFrom, TemplateId = 20661200, TemplateModel = new Dictionary <string, object> { { "name", T.Name }, { "lastname", T.Lastname }, { "resort", resort.Description }, { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") }, { "unitSize", unitSize.Description }, { "priceToPay", stock.Price2Pay }, { "dob", T.Dob }, { "email", T.Email }, { "cell", T.Cell }, { "id", stock.Id }, { "adults", T.Adults }, { "kids", T.Under12 }, { "note", T.Note } } }; var client = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c"); var sendResult = await client.SendMessageAsync(message); if (sendResult.Status == PostmarkStatus.Success) { Console.WriteLine(sendResult.Status); } else { Console.WriteLine(sendResult.Status); } }
public async Task EmailToClientAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize) { var message = new TemplatedPostmarkMessage { To = T.Email, From = EmailFrom, TemplateId = 20752183, TemplateModel = new Dictionary <string, object> { { "name", T.Name }, { "resort", resort.Description }, { "date", stock.Arrival.Date.ToString("dd/MM/yyyy") }, { "nights", stock.Nights }, { "unitsize", unitSize.Description }, { "priceToPay", stock.Price2Pay }, { "link", resort.Link }, { "adults", T.Adults }, { "kids", T.Under12 }, { "note", T.Note } } }; var client = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c"); var sendResult = await client.SendMessageAsync(message); if (sendResult.Status == PostmarkStatus.Success) { Console.WriteLine(sendResult.Status); } else { Console.WriteLine(sendResult.Status); } }
public async Task EmailToProviderAsync(EnquiryDto T, Vacation stock, Resort resort, Supplier supplier, UnitSizes unitSize) { var message = new TemplatedPostmarkMessage { To = supplier.Email, From = EmailFrom, TemplateId = 13249489, TemplateModel = new Dictionary <string, object> { { "provider", supplier.Description }, { "resort", resort.Description }, { "arrival", stock.Arrival.Date.ToString("dd/MM/yyyy") }, { "nights", stock.Nights }, { "unitSize", unitSize.Description }, { "product_name", "Holiday Booker" }, { "company_name", "Holiday Booker" } } }; var client = new PostmarkClient("ba4b7707-54c8-49d7-83d5-e215483fe37c"); var sendResult = await client.SendMessageAsync(message); if (sendResult.Status == PostmarkStatus.Success) { Console.WriteLine(sendResult.Status); } else { Console.WriteLine(sendResult.Status); } }