public AttributeGroupViewModel GetAttributeGroupById(int attributeGroupId) { AttributeGroup attributeGroup = _ctx.AttributeGroups.FirstOrDefault(f => f.Id == attributeGroupId); AttributeGroupViewModel attributeGroupViewModel = AttributeGroupFactory.AttributeGroupToViewModel(attributeGroup); return(attributeGroupViewModel); }
public List <AttributeGroupViewModel> GetAllAttributeGroups() { List <AttributeGroup> attributeGroups = _ctx.AttributeGroups.ToList(); List <AttributeGroupViewModel> attributeGroupViewModel = new List <AttributeGroupViewModel>(); attributeGroups.ForEach(attributeGroup => { attributeGroupViewModel.Add(AttributeGroupFactory.AttributeGroupToViewModel(attributeGroup)); }); return(attributeGroupViewModel); }
public HttpStatusCode CreateAttributeGroup(CreateAttributeGroupDto createAttributeGroupDto) { AttributeGroup attributeGroup = AttributeGroupFactory.AttributeGroupToDbo(createAttributeGroupDto); try { _ctx.AttributeGroups.Add(attributeGroup); _ctx.SaveChanges(); return(HttpStatusCode.OK); } catch (Exception ex) { return(HttpStatusCode.InternalServerError); } }