public IHttpActionResult add(WeddingDto dto) { var customerId = uow.Customers.GetAll().Single(x => x.Email == Username).Id; var wedding = new Wedding() { NumberOfGuests = dto.NumberOfGuests, Location = dto.Location, NumberOfHours = dto.NumberOfHours, CustomerId = customerId, Date = dto.Date, Categories = dto.Categories.Select(x => new Category() { Name = x.Name }).ToList() }; this.repository.Add(wedding); this.uow.SaveChanges(); dto.Id = wedding.Id; var context = GlobalHost.ConnectionManager.GetHubContext<WeddingHub>(); context.Clients.All.onWeddingAdded(new { Data = dto }); return Ok(dto); }
public IHttpActionResult update(WeddingDto dto) { var wedding = new Wedding() { NumberOfGuests = dto.NumberOfGuests }; repository.Add(wedding); uow.SaveChanges(); return Ok(wedding); }
public IHttpActionResult GetById(int id) { var wedding = this.repository.GetAll().Where(x => x.Id == id && x.IsDeleted == false).Single(); var dto = new WeddingDto() { Id = wedding.Id, NumberOfGuests = wedding.NumberOfGuests, NumberOfHours = wedding.NumberOfHours, Location = wedding.Location }; return Ok(dto); }