Exemple #1
0
    public ActionResult Update(Learning oldLearning, Learning newLearning, int[] newAssistants, int userId, int companyId)
    {
        var    res       = ActionResult.NoAction;
        string extradata = Learning.Differences(oldLearning, newLearning);

        if (!string.IsNullOrEmpty(extradata))
        {
            res = newLearning.Update(userId);
            if (res.Success)
            {
                ActivityLog.Learning(newLearning.Id, userId, companyId, LearningLogActions.Modified, extradata);
                res.SetSuccess(newLearning.Id.ToString());
            }
        }

        foreach (int assistantId in newAssistants)
        {
            var newAssistant = new Assistant
            {
                CompanyId = companyId,
                Completed = null,
                Success   = null,
                Learning  = new Learning {
                    Id = newLearning.Id
                },
                Employee = new Employee(assistantId, true)
            };

            newAssistant.JobPosition = newAssistant.Employee.JobPosition;
            newAssistant.Insert(userId);
        }

        if (res.MessageError == ActionResult.NoAction.MessageError)
        {
            res.SetSuccess();
        }

        return(res);
    }