public IEnumerable <TicketModels> ApproveTicket(Detail data) { List <TicketModels> results = new List <TicketModels>(); try { IQueryable <WebAPI.DATA.TicketLE.VW_TICKET> View_Ticket; var seach = data.seach; var type = data.type; UserDataContext Con = new UserDataContext(); TicketLEDataContext db = new TicketLEDataContext(); TicketModels value = new TicketModels(); //value.Type = new SelectList(db.MAS_SSes, "SS_ID", "SS_NAME"); var User = (from xx in Con.MAS_USERs join yy in Con.MAS_DEPs on xx.D_ID equals yy.DP_ID where xx.STCODE == data.STCODE select new { xx, yy }).FirstOrDefault(); //value.DP = User.xx.D_ID; using (TicketLEDataContext Context = new TicketLEDataContext()) { View_Ticket = Context.VW_TICKETs.Where(s => s.TICKETNO.Contains(seach) || s.DPCODE.Contains(seach) || s.NICKNAME.Contains(seach)).Where(s => s.STATUS == "1").Where(s => s.FLAG == "1").Where(s => s.APPROVE_ID == 1).Where(s => s.DPCODE == User.yy.DPCODE).OrderBy(s => s.STATUS); List <Ticket> ticketsAns = new List <Ticket>(); foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; ticketsAns.Add(ux); } value.TicketDetail = ticketsAns; } //value.WordSearch = seach; //value.typeSearch = type; results.Add(value); } catch (Exception ex) { //Detail res = new Detail(); //res.status = "F"; //res.message = ex.Message; //results.Add(res); } return(results.ToArray()); }
public IEnumerable <Ticket> Ticketlist(Detail data) { List <Ticket> results = new List <Ticket>(); try { IQueryable <DATA.TicketLE.VW_TICKET> View_Ticket; var seach = data.seach; var type = data.type; UserDataContext Con = new UserDataContext(); TicketLEDataContext db = new TicketLEDataContext(); List <Ticket> lstTicket = new List <Ticket>(); var User = (from xx in Con.MAS_USERs where xx.STCODE == data.STCODE select xx).FirstOrDefault(); using (TicketLEDataContext Context = new TicketLEDataContext()) { View_Ticket = Context.VW_TICKETs.Where(s => s.TICKETNO.Contains(seach) || s.DPCODE.Contains(seach) || s.NICKNAME.Contains(seach)).Where(s => s.FLAG == "1").OrderBy(s => s.STATUS); if (type != "") { View_Ticket = View_Ticket.Where(tik => tik.STATUS == type); } if (User.D_ID != 10) { View_Ticket = View_Ticket.Where(s => s.STCODE == data.STCODE); foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; lstTicket.Add(ux); } } else { if (User.A_ID == 3) { View_Ticket = View_Ticket.Where(s => s.STCODE == data.STCODE); } else { View_Ticket = View_Ticket.Where(s => s.APPROVE_ID >= 2); } foreach (var item in View_Ticket) { Ticket ux = new Ticket(); ux.ID = item.ID; ux.TICKETNO = item.TICKETNO; ux.DETAIL = item.DETEIL; ux.CREATEDATE = DateTime.Parse(item.WORKDATE.ToString()).ToShortDateString(); ux.CREATETIME = DateTime.Parse(item.WORKDATE.ToString()).ToLongTimeString(); ux.CRE_NICKNAME = item.NICKNAME; ux.DEP = item.DPCODE; ux.SSID = Int32.Parse(item.STATUS); ux.SSNAME = item.SS_NAME; lstTicket.Add(ux); } } results = lstTicket; } } catch (Exception ex) { //AnsOP res = new AnsOP(); //res.status = "F"; //res.message = ex.Message; //results.Add(res); } return(results.ToArray()); }