public static async Task<object> GetCustomers(CustomerParams param) { using (T_Customer_Entities entity = new T_Customer_Entities()) { return await entity.List(param); } }
public async Task<object> GetRoles(CustomerParams param) { param.CategoryId = "0"; param.Cids = new string[] { }; var data = await T_Customer_BLL.GetCustomers(param); return Ok(new { statusCode = 200, result = data }); }
public async Task<object> GetCustomers(CustomerParams param) { string[] str = new string[] { }; var data = await T_Customer_BLL.GetCustomers(param); return Ok(new { statusCode = 200, result = data }); }
public async Task<object> List(CustomerParams param) { using (db = new KBLDataContext()) { var entities = from c in db.Customers join t in db.CustomerTasks on c.Cid equals t.CId into ct from lct in ct.DefaultIfEmpty() where (c.CategoryID == param.CategoryId && !string.IsNullOrEmpty(param.CategoryId) || string.IsNullOrEmpty(param.CategoryId)) group lct by c into gct select gct; var data = await entities.ToListAsync(); var json = from gct in data orderby gct.Key.Cid descending select new { c = gct.Key, t = new { Unfinished = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date && w.ReviewStatus == false).Select(s => new { s.StartDate, s.ReviewStatus }) : new object { }, //Prev = gct!=null ? gct.Any(a=>a !=null)? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date).OrderBy(o => o.StartDate).Take(1):null : null, Prev = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date < DateTime.Now.Date).OrderBy(o => o.StartDate).LastOrDefault() : null, //Next = gct != null ? gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date).OrderByDescending(o => o.StartDate).Take(1) : null : null, Next = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date).OrderBy(o => o.StartDate).FirstOrDefault() : null, //Today = gct != null ? gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date == DateTime.Now.Date).OrderByDescending(o => o.StartDate).Take(1) : null : null Today = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date == DateTime.Now.Date).OrderByDescending(o => o.StartDate).LastOrDefault() : null, Finishing = gct.Any(a => a != null) ? gct.Where(w => w.StartDate.Value.Date > DateTime.Now.Date && w.ReviewStatus == false).Select(s=>new { s.StartDate, s.ReviewStatus }) : new object{ }, } }; return json; } }