コード例 #1
0
        public IHttpActionResult Put(TeamMessagingEdit teamMessage)

        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateTeamMessagingService();

            if (!service.UpdateTeamMessage(teamMessage))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
コード例 #2
0
 public bool UpdateTeamMessage(TeamMessagingEdit model)
 {
     using (var ctx = new ApplicationDbContext())
     {
         byte[] bytes = null;
         if (model.File != null)
         {
             Stream       fs = model.File.InputStream;
             BinaryReader br = new BinaryReader(fs);
             bytes = br.ReadBytes((Int32)fs.Length);
         }
         var entity =
             ctx
             .TeamMessaging
             .Single(e => e.MessageID == model.MessageID && e.UserID == _userID);
         entity.FileContent = bytes;
         entity.Title       = model.Title;
         entity.Content     = model.Content;
         entity.Modifiedutc = DateTimeOffset.Now;
         return(ctx.SaveChanges() == 1);
     }
 }