public static DailyReport TryParse(string marketName, string productIdStr, string quantityStr, string priceStr, string dateStr) { DailyReport newDaySale = null; int id = 0; int quantity = 0; decimal price = 0m; DateTime date = DateTime.Now; bool dateParsed = DateTime.TryParseExact(dateStr, "dd-MMM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date); bool idParsed = int.TryParse(productIdStr, out id); bool quantityParsed = int.TryParse(quantityStr, out quantity); bool priceParsed = decimal.TryParse(priceStr, out price); if (idParsed && quantityParsed && priceParsed && dateParsed) { newDaySale = new DailyReport(marketName, id, quantity, price, date); } return newDaySale; }
public static DailyReport TryParse(string marketName, string productIdStr, string quantityStr, string priceStr, string dateStr) { DailyReport newDaySale = null; int id = 0; int quantity = 0; decimal price = 0m; DateTime date = DateTime.Now; bool dateParsed = DateTime.TryParseExact(dateStr, "dd-MMM-yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out date); bool idParsed = int.TryParse(productIdStr, out id); bool quantityParsed = int.TryParse(quantityStr, out quantity); bool priceParsed = decimal.TryParse(priceStr, out price); if (idParsed && quantityParsed && priceParsed && dateParsed) { newDaySale = new DailyReport(marketName, id, quantity, price, date); } return(newDaySale); }