/// <summary> /// Assigns the values of a Style entity's /// properties to the properties of a Style /// data model. /// </summary> /// <param name="style">The Style entity /// containing the property values to assign. /// </param> /// <param name="dbStyle">The Style data /// model to receive the property values. /// </param> private void AssignEntityToModel(StyleEntity style, Style dbStyle) { dbStyle.Name = style.Name; dbStyle.StyleId = style.StyleId; dbStyle.Category = ConvertToModel(style.Category); dbStyle.Slug = style.Slug; }
public static StyleModel ToModel(StyleEntity styleEntity) { if (styleEntity == null) { return(null); } return(new StyleModel { Description = styleEntity.Description, Id = styleEntity.Id, Name = styleEntity.Name }); }
/// <summary> /// Converts a recipe entity into the display model sent /// to the view. /// </summary> /// <param name="entity">The entity to convert</param> /// <returns>A RecipeDisplayViewModel that represents the underlying domain entity</returns> private StyleDisplayViewModel ToDisplayModel(StyleEntity entity) { if (entity == null) { throw new ArgumentNullException( "entity", "Cannot convert an entity to a view model when no entity is passed."); } return(new StyleDisplayViewModel { StyleId = entity.StyleId, Name = entity.Name, Slug = entity.Slug, Category = entity.Category.ToString() }); }
public StyleDisplayViewModel EntityToViewModel(StyleEntity entity) { throw new NotImplementedException(); }
public void Delete(StyleEntity style) { _context.Style.Remove(style); }
public void Update(StyleEntity style) { _context.Entry(style).State = EntityState.Modified; _context.Style.Update(style); }
public void Create(StyleEntity style) { _context.Style.Add(style); }