示例#1
0
 /// <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;
 }
示例#2
0
 public static StyleModel ToModel(StyleEntity styleEntity)
 {
     if (styleEntity == null)
     {
         return(null);
     }
     return(new StyleModel
     {
         Description = styleEntity.Description,
         Id = styleEntity.Id,
         Name = styleEntity.Name
     });
 }
示例#3
0
        /// <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();
 }
示例#5
0
 public void Delete(StyleEntity style)
 {
     _context.Style.Remove(style);
 }
示例#6
0
 public void Update(StyleEntity style)
 {
     _context.Entry(style).State = EntityState.Modified;
     _context.Style.Update(style);
 }
示例#7
0
 public void Create(StyleEntity style)
 {
     _context.Style.Add(style);
 }