Exemplo n.º 1
0
		public HttpResponseMessage Put([FromBody]NewEvent newEvent)
		{
			var user = Db.Users.Local.First();

			var @event = new Event
			{
				UserId = user.Id,
				Id = Guid.NewGuid(),
				Name = newEvent.Name,
				CreatedOn = DateTime.UtcNow
			};

			Db.Events.Add(@event);

			Db.SaveChanges();

			var response = Request.CreateResponse(HttpStatusCode.Created, new ExistingEvent(@event));
			response.Headers.Location = new Uri(Request.RequestUri + "/" + @event.Id);

			return response;
		}
Exemplo n.º 2
0
 public ExistingEvent(Event @event)
 {
     Id = @event.Id;
     CreatedOn = @event.CreatedOn;
     Name = @event.Name;
 }