public override DTO.EditFormData GetData(int userId, int id, Hashtable param, out Library.DTO.Notification notification) { DTO.EditFormData editFormData = new DTO.EditFormData(); notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; try { using (ProductionStatisticsMngEntities context = CreateContext()) { int?companyID = fw_factory.GetCompanyID(userId); if (id > 0) { var dbItem = context.ProductionStatisticsMng_ProductionStatistics_View.Where(o => o.CompanyID == companyID).FirstOrDefault(o => o.ProductionStatisticsID == id); editFormData.Data = converter.DB2DTO_ProductionStatistics(dbItem); } else { //initialize item data base on selected workorder int workCenterID = Convert.ToInt32(param["workCenterID"]); string producedDate = param["producedDate"].ToString(); //init value editFormData.Data.WorkCenterID = workCenterID; editFormData.Data.ProducedDate = producedDate; editFormData.Data.WorkCenterNM = new Module.Support.DAL.DataFactory().GetWorkCenter().Where(o => o.WorkCenterID == workCenterID).FirstOrDefault().WorkCenterNM; //get planning production by workcenter var planningProductionTeam = context.ProductionStatisticsMng_function_GetPlanningProductionTeam(companyID, workCenterID, producedDate).ToList(); editFormData.Data.ProductionStatisticsDetailDTOs = AutoMapper.Mapper.Map <List <ProductionStatisticsMng_PlanningProductionTeam_View>, List <DTO.ProductionStatisticsDetailDTO> >(planningProductionTeam); } } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(editFormData); }
public List <DTO.PlanningProductionTeamDTO> GetPlanningProductionTeam(int userId, int workCenterID, string producedDate, out Library.DTO.Notification notification) { notification = new Library.DTO.Notification() { Type = Library.DTO.NotificationType.Success }; List <DTO.PlanningProductionTeamDTO> data = new List <DTO.PlanningProductionTeamDTO>(); try { using (ProductionStatisticsMngEntities context = CreateContext()) { int?companyID = fw_factory.GetCompanyID(userId); var planningProductionTeam = context.ProductionStatisticsMng_function_GetPlanningProductionTeam(companyID, workCenterID, producedDate).ToList(); data = AutoMapper.Mapper.Map <List <ProductionStatisticsMng_PlanningProductionTeam_View>, List <DTO.PlanningProductionTeamDTO> >(planningProductionTeam); } } catch (Exception ex) { notification.Type = Library.DTO.NotificationType.Error; notification.Message = Library.Helper.GetInnerException(ex).Message; } return(data); }