public ManageResourcesResponse ResourceAllocated(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); //int? empId = AdapterHelper.GetEmployeeId(request.EmployeeName, request.Email); //if (!empId.HasValue) // throw new Exception("Employee does not exist!"); List <resourceDTO> res = new List <resourceDTO>(); List <Resources_table> resource = new List <Resources_table>(); using (var context = new Company_dbEntities()) { resource = (from a in context.Resources_table where a.EmployeeID == request.UserName && a.Deleted == false select a).ToList(); if (resource != null) { foreach (var entry in resource) { resourceDTO r = new resourceDTO(); r.NameOfDevice = entry.NameOfDevice; r.Type = entry.Type; r.IssuedTo = entry.IssuedTo; // r.IssuedFrom = entry.IssuedFrom.ToString(); res.Add(r); } } response.ResourcesAllocated = JsonConvert.SerializeObject(res); } return(response); }
public ManageResourcesResponse ShowImage(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); using (var context = new Company_dbEntities()) { var image = (from a in context.Resources_table where a.Serial == request.Serial select a).FirstOrDefault(); if (image != null) { resourceDTO r = new resourceDTO(); r.Picture = image.Picture; response.resourceImage = r.Picture; } } return(response); }
public ManageResourcesResponse ShowResources(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); int?compId = AdapterHelper.GetCompanyId(request.CompanyName); if (compId == null) { throw new Exception("No company found. Try again!"); } List <resourceDTO> res = new List <resourceDTO>(); List <Resources_table> resource = new List <Resources_table>(); using (var context = new Company_dbEntities()) { resource = (from a in context.Resources_table where a.CompanyID == compId.Value select a).ToList(); if (resource != null) { foreach (var entry in resource) { resourceDTO r = new resourceDTO(); r.NameOfDevice = entry.NameOfDevice; r.Type = entry.Type; r.IssuedFrom = entry.IssuedFrom.ToString(); r.EmployeeID = entry.EmployeeID; r.Serial = entry.Serial; r.CompanyID = entry.CompanyID; r.Deleted = entry.Deleted; r.Picture = entry.Picture; r.IsActive = entry.IsActive; res.Add(r); } } response.ResourcesList = JsonConvert.SerializeObject(res); } return(response); }
public ManageResourcesResponse ShowResources(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); int? compId = AdapterHelper.GetCompanyId(request.CompanyName); if (compId == null) { throw new Exception("No company found. Try again!"); } List<resourceDTO> res = new List<resourceDTO>(); List<Resources_table> resource = new List<Resources_table>(); using (var context = new Company_dbEntities()) { resource = (from a in context.Resources_table where a.CompanyID == compId.Value select a).ToList(); if (resource != null) { foreach(var entry in resource) { resourceDTO r = new resourceDTO(); r.NameOfDevice = entry.NameOfDevice; r.Type = entry.Type; r.IssuedFrom = entry.IssuedFrom.ToString(); r.EmployeeID = entry.EmployeeID; r.Serial = entry.Serial; r.CompanyID = entry.CompanyID; r.Deleted = entry.Deleted; r.Picture = entry.Picture; r.IsActive = entry.IsActive; res.Add(r); } } response.ResourcesList = JsonConvert.SerializeObject(res); } return response; }
public ManageResourcesResponse ShowImage(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); using (var context = new Company_dbEntities()) { var image = (from a in context.Resources_table where a.Serial == request.Serial select a).FirstOrDefault(); if(image != null) { resourceDTO r = new resourceDTO(); r.Picture = image.Picture; response.resourceImage = r.Picture; } } return response; }
public ManageResourcesResponse ResourceAllocated(ManageResourcesRequest request) { ManageResourcesResponse response = new ManageResourcesResponse(); //int? empId = AdapterHelper.GetEmployeeId(request.EmployeeName, request.Email); //if (!empId.HasValue) // throw new Exception("Employee does not exist!"); List<resourceDTO> res = new List<resourceDTO>(); List<Resources_table> resource = new List<Resources_table>(); using (var context = new Company_dbEntities()) { resource = (from a in context.Resources_table where a.EmployeeID == request.UserName && a.Deleted == false select a).ToList(); if (resource != null) { foreach (var entry in resource) { resourceDTO r = new resourceDTO(); r.NameOfDevice = entry.NameOfDevice; r.Type = entry.Type; r.IssuedTo = entry.IssuedTo; // r.IssuedFrom = entry.IssuedFrom.ToString(); res.Add(r); } } response.ResourcesAllocated = JsonConvert.SerializeObject(res); } return response; }