/// <summary> /// Save CostCenters /// </summary> /// <param name="CostCenterList"></param> /// <returns></returns> // POST: api/CostCenter public IHttpActionResult Post([FromBody] List <CostCenter> CostCenterList) { CostCenterRepository CostCenterRepository = new CostCenterRepository(Convert.ToInt32(Request.Headers.GetValues("CurrentUserID").First())); CostCenterRepository.SaveCostCenters(CostCenterList); return(Json(new { count = CostCenterList.Count.ToString() })); }
/// <summary> /// Get CostCenters /// </summary> /// <returns></returns> // GET: api/CostCenter public IHttpActionResult Get() { CostCenterRepository CostCenterRepository = new CostCenterRepository(Convert.ToInt32(Request.Headers.GetValues("CurrentUserID").First())); List <CostCenter> CostCenterList = CostCenterRepository.GetCostCenters(); return(Json(new { CostCenters = CostCenterList })); }
public ActionResult CostCenters() { try { List <CostCenter> costcenters; CostCenter working = AuthManager.GetWorkingCostCenter(); Employee employee = AuthManager.GetEmployeeInfo(); CostCenterManager ccaManager = new CostCenterManager(); int deptsap; DepartmentInfo deptInfo; using (var db = new BudgetContext()) { deptInfo = db.DepartmentInfos.FirstOrDefault(d => d.CostCenterCode == working.CostCenterID); } if (deptInfo == null) { using (var ccRepo = new CostCenterRepository()) { costcenters = ccRepo.Get() .Where(c => c.CostCenterID.StartsWith(working.CostCenterTrim) && c.Status == RecordStatus.Active ).OrderBy(c => c.CostCenterID).ToList(); } } else { deptsap = deptInfo.DeptSap; costcenters = ccaManager.GetWithChildren(deptsap); } returnobj.SetSuccess(costcenters); //using (var ccRepo = new CostCenterRepository()) //{ // costcenters = ccRepo.Get() // .Where(c => // c.CostCenterID.StartsWith(working.CostCenterTrim) && // c.Status == RecordStatus.Active // ).OrderBy(c => c.CostCenterID).ToList(); //} // } catch (Exception ex) { returnobj.SetError(ex.Message); } return(Content(returnobj.ToJson(), "application/json")); }
public ActionResult CostCenter(string id) { try { if (id == null) { return(CostCenters()); } CostCenter costcenter; using (var ccRepo = new CostCenterRepository()) { costcenter = ccRepo.GetById(id); } returnobj.SetSuccess(costcenter); } catch (Exception ex) { returnobj.SetError(ex.Message); } return(Content(returnobj.ToJson(), "application/json")); }
public CostCenterService() { _costCenterRepository = new CostCenterRepository(); _sortingService = new SortingService(); _paginationService = new PaginationService(); }