public void Should_create(TestContextFixture fixture, Department dept) { fixture.SaveAll(dept); var command = new Create.Command { Title = "Blarg", Credits = 10, Department = dept }; fixture.Send(command); Course course = null; fixture.DoClean(ctx => course = ctx.Set<Course>().FirstOrDefault(c => c.Title == command.Title)); course.Title.ShouldBe(command.Title); course.Credits.ShouldBe(command.Credits); course.DepartmentID.ShouldBe(dept.DepartmentID); }
public static async Task <Appointment> CreateAppointment(TestFixture fixture, Create.Command command) { var dbContext = fixture.GetDbContext(); var appointmentCreateHandler = new Create.Handler(dbContext); var created = await appointmentCreateHandler.Handle(command, new CancellationToken()); var dbAppointment = await fixture.ExecuteDbContextAsync(db => db.Appointments .Where(a => a.AppointmentId == created.Appointment.AppointmentId) .SingleOrDefaultAsync()); return(dbAppointment); }
public async Task <IActionResult> Post([FromBody] Create.Command model) { await Mediator.Send(model); return(NoContent()); }
public async Task <ActionResult <Unit> > Create(Create.Command command) { await _mediator.Send(command); return(CreatedAtRoute("Action_Detail", new { id = command.Id }, command)); }
/// <summary> /// creates an article comment based on the given Create command. /// Creates a default user if parameter userName is empty. /// </summary> /// <param name="fixture"></param> /// <param name="command"></param> /// <param name="userName"></param> /// <returns></returns> public static async Task <Domain.Comment> CreateComment(SliceFixture fixture, Create.Command command, string userName) { if (string.IsNullOrWhiteSpace(userName)) { var user = await UserHelpers.CreateDefaultUser(fixture); userName = user.Username; } var dbContext = fixture.GetDbContext(); var currentAccessor = new StubCurrentUserAccessor(userName); var commentCreateHandler = new Create.Handler(dbContext, currentAccessor); var created = await commentCreateHandler.Handle(command, new System.Threading.CancellationToken()); var dbArticleWithComments = await fixture.ExecuteDbContextAsync( db => db.Articles .Include(a => a.Comments).Include(a => a.Author) .Where(a => a.Slug == command.Slug) .SingleOrDefaultAsync() ); var dbComment = dbArticleWithComments.Comments .Where(c => c.ArticleId == dbArticleWithComments.ArticleId && c.Author == dbArticleWithComments.Author) .FirstOrDefault(); return(dbComment); }
public async Task Should_create_new_course(ContosoUniversityCore.Features.Instructor.CreateEdit.Command instructor, Department dept, Create.Command command) { var adminId = await SendAsync(instructor); var admin = await FindAsync <Instructor>(adminId); dept.Administrator = admin; await InsertAsync(dept); command.Department = dept; await SendAsync(command); var created = await ExecuteDbContextAsync(db => db.Courses.Where(c => c.Id == command.Number).SingleOrDefaultAsync()); created.ShouldNotBeNull(); created.DepartmentID.ShouldBe(dept.Id); created.Credits.ShouldBe(command.Credits); created.Title.ShouldBe(command.Title); }
public async Task <ActionResult <Unit> > Create(Create.Command command) { return(await _mediator.Send(command)); }
public async Task <IActionResult> Create(Create.Command request) { var response = await _mediator.Send(request); return(CreatedAtRoute("api/category", response)); }
public async Task SendComment(Create.Command command) { var comment = await _mediator.Send(command); // without await will return task await Clients.Group(command.ActivityId.ToString()).SendAsync("ReceiveComment", comment.Value); }
public async Task <ActionResult <GameDto> > Create(Create.Command command) { return(await Mediator.Send(command)); }
public async Task <ActionResult <Unit> > Create([FromBody] Create.Command command) { return(await Mediator.Send(command)); }
public async Task <Unit> Books(Create.Command command) { _logger.LogInformation($"post:api/book"); return(await Mediator.Send(command)); }
/// <summary> /// creates an article based on the given Create command. It also creates a default user /// </summary> /// <param name="fixture"></param> /// <param name="command"></param> /// <returns></returns> public static async Task <Domain.Article> CreateArticle(SliceFixture fixture, Create.Command command) { // first create the default user var user = await UserHelpers.CreateDefaultUser(fixture); var dbContext = fixture.GetDbContext(); var currentAccessor = new StubCurrentUserAccessor(user.Username); var articleCreateHandler = new Create.Handler(dbContext, currentAccessor); var created = await articleCreateHandler.Handle(command, new System.Threading.CancellationToken()); var dbArticle = await fixture.ExecuteDbContextAsync(db => db.Articles.Where(a => a.ArticleId == created.Article.ArticleId) .SingleOrDefaultAsync()); return(dbArticle); }
public async Task <IActionResult> Post(Create.Command command) { var result = await Mediator.Send(command); return(Ok(result)); }
public async Task <UserEnvelope> Create(Create.Command command) { return(await _mediator.Send(command)); }
public async Task <IActionResult> SetBudget(Create.Command request) { var response = await _mediator.Send(request); return(Ok(response)); }
public async Task <long> Create(Create.Command command) { return(await Mediator.Send(command)); }
public async Task <IActionResult> Create(Create.Command command) => await _mediator.Send(command) switch
public async Task <StatusAction> CreateCourse(Create.Command command) => await Mediator.Send(command);
public async Task SendMessage(Create.Command command) { var message = await _mediator.Send(command); await Clients.All.SendAsync("ReciveMessage", message); }
public ActionResult Create() { var command = new Create.Command(); return View(command); }
public async Task <ActionResult <Unit> > Create(Create.Command activity) { return(await Mediator.Send(activity)); }