public CategoryView(Category model)
 {
     Mapper.CreateMap<Category, CategoryView>();
     Mapper.Map<Category, CategoryView>(model, this);
     this.parentId = model.parent == null ? null : (int?)model.parent.id;
 }
        public Category getModel(IRepository repo)
        {
            var model = new Category()
            {
                description = this.description,
                id = this.id,
                name = this.name,
                salary = this.salary,
                parent = this.parentId == null ? null : repo.getCategory((int)this.parentId),
                order = this.order,
                url = this.url
            };

            return model;
        }
 public Category createCategory(Category model)
 {
     db.categories.Add(model);
     db.SaveChanges();
     return model;
 }