public void Create_New_UserGroup() { var userGroup = new UserGroup { UserId = 1, GroupId = 1 }; _context.Add(userGroup); _context.SaveChanges(); _context.Remove(userGroup); _context.SaveChanges(); }
public ActionResult Post([FromBody] MeetupDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var meetup = _mapper.Map <Meetup>(model); _meetupContext.Add(meetup); _meetupContext.SaveChanges(); var key = meetup.Name.Replace(" ", "-").ToLower(); return(Created("api/meetup/" + key, null)); }
public void Crete_New_MeetupEvent_Add_Assistants() { var meetupEvent = new MeetupEvent(); _context.Add(meetupEvent); _context.SaveChanges(); meetupEvent.AddAssistant(_context.Users.First()); _context.SaveChanges(); meetupEvent.Assistants.Count().Should().Be(1); _context.Remove(meetupEvent); _context.SaveChanges(); }
public void Crete_New_MeetupEvent_Add_Assistants() { //TODO: 04 - Creo un nuevo evento y le agrego un asistente var meetupEvent = new MeetupEvent(); _context.Add(meetupEvent); _context.SaveChanges(); meetupEvent.AddAssistant(_context.Users.First()); _context.SaveChanges(); meetupEvent.Assistants.Count().Should().Be(1); _context.Remove(meetupEvent); _context.SaveChanges(); }
public ActionResult Post([FromBody] MeetupDto model) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var meetup = _mapper.Map <Meetup>(model); var userId = User.FindFirst(c => c.Type == ClaimTypes.NameIdentifier).Value; meetup.CreatedById = int.Parse(userId); _meetupContext.Add(meetup); _meetupContext.SaveChanges(); var key = meetup.Name.Replace(" ", "-").ToLower(); return(Created("api/meetup/" + key, null)); }