public IHttpActionResult GetPlaceAction(string token, int id) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from pa in db.JDE_PlaceActions join p in db.JDE_Places on pa.PlaceId equals p.PlaceId into Places from pls in Places.DefaultIfEmpty() join a in db.JDE_Actions on pa.ActionId equals a.ActionId into Actions from acs in Actions.DefaultIfEmpty() join u in db.JDE_Users on pa.CreatedBy equals u.UserId join u2 in db.JDE_Users on pa.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join t in db.JDE_Tenants on pa.TenantId equals t.TenantId where pa.TenantId == tenants.FirstOrDefault().TenantId&& pa.PlaceActionId == id orderby pa.CreatedOn descending select new { PlaceActionId = pa.PlaceActionId, PlaceId = pa.PlaceId, PlaceName = pls.Name, ActionId = pa.ActionId, ActionName = acs.Name, GivenTime = acs.GivenTime, Type = acs.Type, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = pa.CreatedOn, LmBy = pa.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = pa.TenantId, TenantName = t.TenantName, LastChecks = (from pact in db.JDE_ProcessActions join h in db.JDE_Handlings on pact.HandlingId equals h.HandlingId into Handlings from hs in Handlings.DefaultIfEmpty() where pact.ActionId == pa.ActionId && pact.IsChecked == true orderby hs.FinishedOn descending select hs.FinishedOn).Take(1) }); if (items.Any()) { return(Ok(items.FirstOrDefault())); } else { return(StatusCode(HttpStatusCode.NoContent)); } } else { return(NotFound()); } } else { return(NotFound()); } }
public IHttpActionResult GetProcessAssign(string token, int id) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from pa in db.JDE_ProcessAssigns join p in db.JDE_Processes on pa.ProcessId equals p.ProcessId into Processes from prs in Processes.DefaultIfEmpty() join u in db.JDE_Users on pa.CreatedBy equals u.UserId join u2 in db.JDE_Users on pa.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join u3 in db.JDE_Users on pa.UserId equals u3.UserId into Users from usrs in Users.DefaultIfEmpty() join t in db.JDE_Tenants on pa.TenantId equals t.TenantId where pa.TenantId == tenants.FirstOrDefault().TenantId&& pa.ProcessAssignId == id && pa.ProcessAssignId == id orderby pa.CreatedOn descending select new { ProcessAssignId = pa.ProcessAssignId, ProcessId = pa.ProcessId, UserId = usrs.UserId, UserName = usrs.Name + " " + usrs.Surname, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = pa.CreatedOn, LmBy = pa.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = pa.TenantId, TenantName = t.TenantName }); if (items.Any()) { return(Ok(items.FirstOrDefault())); } else { return(StatusCode(HttpStatusCode.NoContent)); } } else { return(NotFound()); } } else { return(NotFound()); } }
public IHttpActionResult GetAction(string token, int id) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from a in db.JDE_Actions join u in db.JDE_Users on a.CreatedBy equals u.UserId join u2 in db.JDE_Users on a.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join t in db.JDE_Tenants on a.TenantId equals t.TenantId where a.TenantId == tenants.FirstOrDefault().TenantId&& a.ActionId == id orderby a.CreatedOn descending select new { ActionId = a.ActionId, Name = a.Name, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = a.CreatedOn, LmBy = a.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = a.TenantId, TenantName = t.TenantName, ActionTypeId = a.ActionTypeId }); if (items.Any()) { return(Ok(items.FirstOrDefault())); } else { return(StatusCode(HttpStatusCode.NoContent)); } } else { return(NotFound()); } } else { return(NotFound()); } }
public IHttpActionResult GetPlaceActions(string token, int page = 0, int total = 0, string query = null) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from pa in db.JDE_PlaceActions join p in db.JDE_Places on pa.PlaceId equals p.PlaceId into Places from pls in Places.DefaultIfEmpty() join a in db.JDE_Actions on pa.ActionId equals a.ActionId into Actions from acs in Actions.DefaultIfEmpty() join u in db.JDE_Users on pa.CreatedBy equals u.UserId join u2 in db.JDE_Users on pa.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join t in db.JDE_Tenants on pa.TenantId equals t.TenantId where pa.TenantId == tenants.FirstOrDefault().TenantId orderby pa.CreatedOn descending select new { PlaceActionId = pa.PlaceActionId, PlaceId = pa.PlaceId, PlaceName = pls.Name, ActionId = pa.ActionId, ActionName = acs.Name, GivenTime = acs.GivenTime, Type = acs.Type, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = pa.CreatedOn, LmBy = pa.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = pa.TenantId, TenantName = t.TenantName, LastChecks = (from pact in db.JDE_ProcessActions join h in db.JDE_Handlings on pact.HandlingId equals h.HandlingId into Handlings from hs in Handlings.DefaultIfEmpty() where pact.ActionId == pa.ActionId && pact.IsChecked == true orderby hs.FinishedOn descending select hs.FinishedOn).Take(1) }); if (items.Any()) { if (query != null) { items = items.Where(query); } if (total == 0 && page > 0) { int pageSize = RuntimeSettings.PageSize; var skip = pageSize * (page - 1); if (skip < items.Count()) { items = items.Skip(skip).Take(pageSize); return(Ok(items)); } else { return(NotFound()); } } else if (total > 0 && page == 0) { items = items.Take(total); return(Ok(items)); } else { return(Ok(items)); } } else { return(NotFound()); } } else { return(NotFound()); } } else { return(NotFound()); } }
public IHttpActionResult GetProcessAssigns(string token, int page = 0, int total = 0, string query = null) { if (token != null && token.Length > 0) { var tenants = db.JDE_Tenants.Where(t => t.TenantToken == token.Trim()); if (tenants.Any()) { var items = (from pa in db.JDE_ProcessAssigns join p in db.JDE_Processes on pa.ProcessId equals p.ProcessId into Processes from prs in Processes.DefaultIfEmpty() join u in db.JDE_Users on pa.CreatedBy equals u.UserId join u2 in db.JDE_Users on pa.LmBy equals u2.UserId into LmByNames from lms in LmByNames.DefaultIfEmpty() join u3 in db.JDE_Users on pa.UserId equals u3.UserId into Users from usrs in Users.DefaultIfEmpty() join t in db.JDE_Tenants on pa.TenantId equals t.TenantId where pa.TenantId == tenants.FirstOrDefault().TenantId orderby pa.CreatedOn descending select new { ProcessAssignId = pa.ProcessAssignId, ProcessId = pa.ProcessId, UserId = usrs.UserId, UserName = usrs.Name + " " + usrs.Surname, CreatedBy = u.UserId, CreatedByName = u.Name + " " + u.Surname, CreatedOn = pa.CreatedOn, LmBy = pa.LmBy, LmByName = lms.Name + " " + lms.Surname, TenantId = pa.TenantId, TenantName = t.TenantName }); if (items.Any()) { if (query != null) { items = items.Where(query); } if (total == 0 && page > 0) { int pageSize = RuntimeSettings.PageSize; var skip = pageSize * (page - 1); if (skip < items.Count()) { items = items.Skip(skip).Take(pageSize); return(Ok(items)); } else { return(NotFound()); } } else if (total > 0 && page == 0) { items = items.Take(total); return(Ok(items)); } else { return(Ok(items)); } } else { return(NotFound()); } } else { return(NotFound()); } } else { return(NotFound()); } }