public List <Inps> Read(string filePath, Period period, InpsType inpsType) { try { DataTable excelData = ReadDataTable(filePath); if (excelData == null || excelData.Rows.Count == 0) { //FileManager fm = new FileManager(; throw new Exception("No data found on excel!"); } List <Inps> npss = new List <Inps>(); for (int i = 0; i < excelData.Rows.Count; i++) { Inps nps = new Inps(); nps.Staff = new Model.Staff(); nps.ResponsibleDepartment = new Department(); //nps.Perspective = new MetricsPerspective() { Id = 1 }; nps.Type = inpsType; nps.Staff.Id = excelData.Rows[i][0] == DBNull.Value ? null : Convert.ToString(excelData.Rows[i][0]); nps.Kpi = excelData.Rows[i][1] == DBNull.Value ? null : Convert.ToString(excelData.Rows[i][1]); nps.Measure = excelData.Rows[i][2] == DBNull.Value ? null : Convert.ToString(excelData.Rows[i][2]); nps.DataSource = excelData.Rows[i][3] == DBNull.Value ? null : Convert.ToString(excelData.Rows[i][3]); nps.ResponsibleDepartment.Id = excelData.Rows[i][4] == DBNull.Value ? null : Convert.ToString(excelData.Rows[i][4]); nps.Target = excelData.Rows[i][5] == DBNull.Value ? 0 : Convert.ToDecimal(excelData.Rows[i][5]); nps.Score = excelData.Rows[i][6] == DBNull.Value ? 0 : Convert.ToDecimal(excelData.Rows[i][6]); nps.Period = period; npss.Add(nps); } excelData.Clear(); return(npss); } catch (Exception) { throw; } }
public bool Modify(Inps inps) { try { Func <STAFF_INPS, bool> predicate = si => si.APPRAISAL_HEADER.Staff_ID == inps.Staff.Id && si.Inps_ID == inps.Id; STAFF_INPS entity = GetEntityBy(predicate); if (entity == null) { return(true); } entity.Score = inps.Score; int rowsAffected = repository.SaveChanges(); if (rowsAffected > 0) { return(true); } else { throw new Exception(NoItemModified); } } catch (NullReferenceException) { throw new NullReferenceException(ArgumentNullException); } catch (UpdateException) { throw new UpdateException(UpdateException); } catch (Exception) { throw; } }