public async Task<IHttpActionResult> PutContent( Guid id, Content content ) { if( !ModelState.IsValid ) { return BadRequest( ModelState ); } if( id != content.Id ) { return BadRequest( ); } db.Entry( content ).State = EntityState.Modified; try { await db.SaveChangesAsync( ); } catch( DbUpdateConcurrencyException ) { if( !ContentExists( id ) ) { return NotFound( ); } else { throw; } } return StatusCode( HttpStatusCode.NoContent ); }
public TaskViewModel(Content content) { ItemId = content.Id.ToString(); Title = content.Title; Description = content.Description; datePublish = content.DateOfPublish; dateFinish = DateTime.Now.AddMonths(1); //foreach( var item in content.SubContents ) //{ // ( this.SubTask as List<TaskViewModel> ).Add( new TaskViewModel( item ) ); //} Done = false; }
public ContentViewModel( Content content ) { this.AuthorPublish = content.AuthorPublish.UserName; this.SubContents = new List<ContentViewModel>( ); foreach( var item in content.SubContents ) { ( this.SubContents as List<ContentViewModel> ).Add( new ContentViewModel( item ) ); } this.DateOfPublish = content.DateOfPublish; this.Description = content.Description; this.Title = content.Title; this.Type = content.Type; this.Value = content.Value; }