public static Catagory Create(string name) { var newCatagory = new Catagory (); newCatagory.Name = name; newCatagory.FullName = name; return newCatagory; }
public IHttpActionResult PostCatagory(Catagory catagory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } catagoryService.AddCatagory(catagory.Name, catagory.ParentID.HasValue ? catagory.ParentID.Value : Guid.Empty); try { unitOfWork.SaveChanges(); } catch (DbUpdateException) { throw; } return CreatedAtRoute("DefaultApi", new { id = catagory.ID }, catagory); }
public void SetCatagory(Catagory catagory,int displayOrder=0) { this.CatagoryID = catagory.ID; //var productCatagorySetting = ProductCatagorySetting.Create(this.ID,catagory.ID,catagory.Name,displayOrder); //this.ProductCatagorySettings.Add(productCatagorySetting); }
public IHttpActionResult PutCatagory(Guid id, Catagory catagory) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != catagory.ID) { return BadRequest(); } //db.Entry(catagory).State = EntityState.Modified; catagoryService.UpdateCatagory(catagory.ID, catagory.Name, catagory.ParentID.HasValue ? catagory.ParentID.Value : Guid.Empty); try { unitOfWork.SaveChanges(); } catch (DbUpdateConcurrencyException) { throw; } return StatusCode(HttpStatusCode.NoContent); }
public void BelongTo(Catagory parentCatagory) { this.Parent = parentCatagory; this.ParentID = parentCatagory.ID; }
public void SetCatagory(Catagory catagory, int displayOrder = 0) { this.CatagoryID = catagory.ID; //var productCatagorySetting = ProductCatagorySetting.Create(this.ID,catagory.ID,catagory.Name,displayOrder); //this.ProductCatagorySettings.Add(productCatagorySetting); }
public void AddChildCatagory(Catagory catagory) { catagory.FullName = this.FullName + "-" + catagory.Name; this.Children.Add(catagory); }