public ActionResult Insert(Learning oldLearning, Learning newLearning, AssistantData[] newAssistants, int userId, int companyId) { var res = ActionResult.NoAction; string extradata = Learning.Differences(oldLearning, newLearning); if (!string.IsNullOrEmpty(extradata)) { // Si se informa la fecha de finalización el estado pasa ser "realizado" if (newLearning.RealFinish.HasValue) { newLearning.Status = 1; } res = newLearning.Insert(userId); if (res.Success) { ActivityLog.Learning(newLearning.Id, userId, companyId, LearningLogActions.Create, extradata); } foreach (var assistant in newAssistants) { var newAssistant = new Assistant { CompanyId = companyId, Completed = null, Success = null, Learning = new Learning { Id = newLearning.Id }, Employee = new Employee(assistant.EmployeeId, true) }; if (newAssistant.Employee.JobPosition != null) { newAssistant.JobPosition = newAssistant.Employee.JobPosition; } newAssistant.Insert(userId); } res.SetSuccess(newLearning.Id); } return(res); }