public ActionResult postPoints(IEnumerable <EmployeePointsViewModel> newRecords) { var datasource = new DataSource <EmployeePointsViewModel>(); if (newRecords != null) { var result = new List <EmpPoints>(); datasource.Data = newRecords; datasource.Total = newRecords.Count(); if (ModelState.IsValid) { if (ServerValidationEnabled) { var errors = _hrUnitOfWork.MenuRepository.Check(new CheckParm { CompanyId = CompanyId, ObjectName = "EmployeePoints", TableName = "EmployeePoints", Columns = Models.Utils.GetModifiedRows(ModelState), Culture = Language }); if (errors.Count() > 0) { datasource.Errors = errors; return(Json(datasource)); } } foreach (EmployeePointsViewModel p in newRecords) { var EmpPoint = new EmpPoints { Balance = (int)p.Balance, EmpId = p.EmpId, PeriodId = p.PeriodId, CreatedTime = System.DateTime.Now, CreatedUser = UserName }; result.Add(EmpPoint); _hrUnitOfWork.DisciplineRepository.Add(EmpPoint); } int periodid = newRecords.Select(a => a.PeriodId).FirstOrDefault(); var PeriodNoobj = _hrUnitOfWork.Repository <DisPeriodNo>().Where(a => a.Id == periodid).FirstOrDefault(); PeriodNoobj.Posted = true; _hrUnitOfWork.DisciplineRepository.Attach(PeriodNoobj); _hrUnitOfWork.DisciplineRepository.Entry(PeriodNoobj).State = EntityState.Modified; datasource.Errors = SaveChanges(Language); } else { datasource.Errors = Models.Utils.ParseErrors(ModelState.Values); } if (datasource.Errors.Count() > 0) { return(Json(datasource)); } else { return(Json(datasource)); } } return(Json(datasource)); }
public void Add(EmpPoints period) { context.EmpPoints.Add(period); }