コード例 #1
0
		public static Message GetValidMessage()
		{
			var message = new Message()
			{
				PostDate = DateTime.Now,
				TeamWork = GetValidTeamWork(),
				SentBy = GetValidUser(),
				Text = "What's going on fellas."
			};

			return message;
		}
コード例 #2
0
		public IHttpActionResult Create(MessageModel messageModel)
		{
			if (!this.ModelState.IsValid)
			{
				return BadRequest(this.ModelState);
			}

			var currentUserId = this.userIdProvider.GetUserId();

			var newMessage = new Message()
			{
				Text = messageModel.Text,
				TeamWorkId = messageModel.TeamWorkId,
				SentById = currentUserId
			};

			this.data.Messages.Add(newMessage);
			this.data.SaveChanges();

			messageModel.Id = newMessage.Id;

			return Ok(messageModel);
		}