public void Post(EvaluationHeader header, Account account) { header.PostedDate = DateTime.Now; header.Status = GetStatusPerId(TransactionStatus.ForApproval.ToInt()); _dbContext.Entry(header).State = EntityState.Modified; _dbContext.SaveChanges(); }
public void Save(EvaluationHeader header, IEnumerable <EvaluationLine> lineitems, Account account) { if (header.Id == 0) { header.Rater = account; header.CreatedBy = account.Username; header.CreationDate = DateTime.Now; _dbContext.Add(header); } else { header.ModifiedBy = account.Username; header.ModifiedDate = DateTime.Now; _dbContext.Entry(header).State = EntityState.Modified; } foreach (var item in lineitems) { item.EvaluationHeader = header; _dbContext.Add(item); } _dbContext.SaveChanges(); }
public IActionResult SubmitEvaluation(IFormCollection form) { var counter = _Evaluation.KeySuccessCounterByKRA(int.Parse(form["kra"].ToString())); var Header = new EvaluationHeader(); var LineItems = new List <EvaluationLine>(); var UserId = 2; //This is just a test data and would be removed once the application was injected with session. Header.CreatedBy = _Evaluation.GetAccountById(UserId).Username; Header.CreationDate = DateTime.Now; Header.KeyResultArea = _Evaluation.KeyResultAreaPerId(int.Parse(form["kra"].ToString())); Header.Rater = _Evaluation.GetAccountById(UserId); Header.Ratee = _Evaluation.GetEmployeePerId(int.Parse(form["employeeid"].ToString())); Header.Remarks = form["remarks"].ToString(); var account = _Evaluation.GetAccountById(UserId); for (int i = 1; i <= counter; i++) { var ratingtablename = "ratingtable-" + i.ToString(); var ratingtableid = int.Parse(form[ratingtablename].ToString()); var ksiname = "ksi-" + i.ToString(); var ksiid = int.Parse(form[ksiname].ToString()); var commentname = "comment-" + i.ToString(); var comment = form[commentname].ToString(); var scorename = "score-" + i.ToString(); var score = decimal.Parse(form[scorename].ToString()); var item = new EvaluationLine { RatingTableItem = _Evaluation.RatingTableItem(ratingtableid), SuccessIndicator = _Evaluation.KeySuccessIndicatorPerId(ksiid), Comment = comment, Score = score, }; LineItems.Add(item); } _Evaluation.Save(Header, LineItems, account); return(RedirectToAction("Create")); }