예제 #1
0
 public MessageViewModel Create(Message entity)
 {
     if (entity == null) return null;
     return new MessageViewModel
     {
         Body = entity.Body,
         Company = this.Create(entity.Company),
         Date = entity.Date,
         Id = entity.Id,
         RelativePath = entity.RelativePath,
         Type = entity.Type.ToString()
     };
 }
예제 #2
0
 // PUT api/<controller>/5
 public void Put(int id, Message message)
 {
     var origMessage = Context.Messages.FirstOrDefault(x => x.Id == id);
     if (!message.Active)
     {
         if (origMessage != null)
         {
             origMessage.Active = false;
             origMessage.ModifiedBy = User.Identity.Name;
             origMessage.ModifiedOn = DateTime.Now;
         }
     }
     Context.Messages.AddOrUpdate(origMessage);
     Context.SaveChanges();
 }