//#region "Get stock Report" //[HttpGet] //public IHttpActionResult GetStockReport(string clientId, int? projectId, int? page, int? count) //{ // try // { // using (MaxMasterDbEntities db = new MaxMasterDbEntities()) // { // var report = db.GetStockReport(clientId, projectId, page, count).ToList(); // var projects = report.GroupBy(x => x.Project).ToList(); // List<StockReport> stockReport = new List<StockReport>(); // if (report.Count() > 0) // { // for (int i = 0; i < projects.Count(); i++) // { // var stkproject = projects[i].FirstOrDefault(); // StockReport StkReport = new StockReport // { // Client = stkproject.ShortName, // ClientId = stkproject.Client, // ProjectId = stkproject.Project, // Project = stkproject.OpportunityName, // Status = stkproject.Status, // Models = report.Where(x => x.Project == stkproject.Project).GroupBy(x => x.ItemModelId).Select(x => x.First()).Select(x => new ProjectItemModel // { // ModelId = x.ItemModelId, // ModelName = x.ModelName, // Items = report.Where(y => y.Project == stkproject.Project && y.ItemModelId == x.ItemModelId).Select(y => new ItemDetails // { // SerialNumber = y.SerialNumber, // MacAddress = y.MACAddress, // ManufacturedDate = y.ManufacturedDate // }).ToList(), // TotalItems = report.Where(y => y.Project == stkproject.Project && y.ItemModelId == x.ItemModelId).Count() // }).ToList(), // }; // stockReport.Add(StkReport); // } // } // return Content(HttpStatusCode.OK, new { stockReport }); // } // } // catch (Exception ex) // { // new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); // return Content(HttpStatusCode.InternalServerError, "An error occured, please try again later"); // } //} //#endregion #region "Get Dispatched stock Report" public IHttpActionResult GetDispatchedStock(string clientId, int?project, DateTime?fromDate, DateTime?toDate, int?page, int?count) { try { using (MaxMasterDbEntities db = new MaxMasterDbEntities()) { var dispatchedStock = db.GetDispatchedStockReport(clientId, project, fromDate, toDate, page, count).ToList(); return(Content(HttpStatusCode.OK, new { dispatchedStock })); } } catch (Exception ex) { new Error().logAPIError(System.Reflection.MethodBase.GetCurrentMethod().Name, ex.ToString(), ex.StackTrace); return(Content(HttpStatusCode.InternalServerError, "An error occured please try again later")); } }