public void raise_trainingUpdated_on_update_training() { var history = new History(); history.Add(new TrainingCreated(Guid.NewGuid(), 1, "TEST", 2, Color.Empty.ToArgb())); var training = new Training(history); training.Update("ESSAI", 3, Color.Empty.ToArgb()); training.UncommitedEvents.GetStream().Should().Contain(new TrainingUpdated(Guid.NewGuid(), 1, "ESSAI", 3, Color.Empty.ToArgb())); }
public ContentResult Update(FormCollection form) { JObject json = new JObject(); json["error"] = false; json["message"] = ""; string[] keys = new string[] { "id", "desc", "title", "faci", "loc", "start-year", "start-month", "start-day", "end-month", "end-year", "end-day" }; if (this.HasValues(form, keys)) { if (!this.CheckLogin(AccountType.Applicant) && ((Employee)this.GetAccount().Profile).Department.Type == DepartmentType.HumanResources) { try { Training th = new Training(Int32.Parse(form.GetValue("id").AttemptedValue)); th.Description = form.GetValue("desc").AttemptedValue; th.Title = form.GetValue("title").AttemptedValue; th.Facilitator = form.GetValue("faci").AttemptedValue; th.Location = form.GetValue("loc").AttemptedValue; th.StartDate = DateTime.ParseExact( form.GetValue("start-year").AttemptedValue + "-" + (Int32.Parse(form.GetValue("start-month").AttemptedValue) + 1).ToString("00") + "-" + Int32.Parse(form.GetValue("start-day").AttemptedValue).ToString("00"), "yyyy-MM-dd", CultureInfo.InvariantCulture); th.EndDate = DateTime.ParseExact( form.GetValue("end-year").AttemptedValue + "-" + (Int32.Parse(form.GetValue("end-month").AttemptedValue) + 1).ToString("00") + "-" + Int32.Parse(form.GetValue("end-day").AttemptedValue).ToString("00"), "yyyy-MM-dd", CultureInfo.InvariantCulture); th.Update(); } catch (Exception e) { json["error"] = true; json["message"] = e.Message; } } else { json["error"] = true; json["message"] = "You are not authorized to continue"; } json["error"] = true; json["message"] = "Form is incomplete"; } return(Content(json.ToString(), "application/json")); }
public void dont_raise_update_if_last_update_equal() { var history = new History(); var trainingId = Guid.NewGuid(); history.Add(new TrainingCreated(trainingId, 1, "TED", 1, Color.Empty.ToArgb())); history.Add(new TrainingUpdated(trainingId, 2, "WELL", 1, Color.Empty.ToArgb())); var training = new Training(history); training.Update("WELL", 1, Color.Empty.ToArgb()); training.UncommitedEvents.GetStream().Should().BeEmpty(); }
public void BuyTraining() { Training.Update(); WorkRemaining += (int)Training.Cost; }