public IEnumerable <ViewVendor> Get() { try { var context = new NestinDBEntities(); var vendor = (from vend in context.ViewVendors select vend); if (vendor.Count() < 1) { ViewVendor tempVendor = new ViewVendor(); tempVendor.VendorID = 9999; tempVendor.Address = "Nothing"; tempVendor.ContactNumber = "11111111"; tempVendor.ShopCategory = "Water"; tempVendor.VendorName = "NA"; List <ViewVendor> temp = new List <ViewVendor> { tempVendor }; return(temp.AsQueryable()); } else { return(vendor); } } catch (Exception ex) { Log.log("Exception Occured at : " + DateTime.Now.ToString() + "----" + ex.Message); return(null); } }
public IEnumerable <ViewVendor> Get(String date, int SocID) { DateTime lastDateTime = DateTime.ParseExact(date, "dd/mm/yyyy HH:MM:SS", null); Log.log("Date found is : " + lastDateTime.ToLongDateString()); String sdate = "23/10/2016 4:05:00"; DateTime newDateTime = Convert.ToDateTime(sdate); Log.log("new Date found is : " + newDateTime.ToLongDateString()); try { var context = new NestinDBEntities(); var vendor = (from vend in context.ViewVendors where vend.InsertDate > lastDateTime && vend.SocietyID == SocID select vend ); if (vendor.Count() < 1) { ViewVendor tempVendor = new ViewVendor(); tempVendor.VendorID = 9999; tempVendor.Address = "No Data"; tempVendor.ContactNumber = "11111111"; tempVendor.ShopCategory = "Water"; tempVendor.VendorName = "NA"; List <ViewVendor> temp = new List <ViewVendor> { tempVendor }; return(temp.AsQueryable()); } else { return(vendor); } } catch (Exception ex) { Log.log("Exception Occured at : " + DateTime.Now.ToString() + "----" + ex.Message); return(null); } }