Пример #1
0
 public static Catagory Create(string name)
 {
     var newCatagory = new Catagory ();
     newCatagory.Name = name;
     newCatagory.FullName = name;
     return newCatagory;
 }
Пример #2
0
        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);
        }
Пример #3
0
 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);
 }
Пример #4
0
        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);
        }
Пример #5
0
 public void BelongTo(Catagory parentCatagory)
 {
     this.Parent   = parentCatagory;
     this.ParentID = parentCatagory.ID;
 }
Пример #6
0
 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);
 }
Пример #7
0
 public void BelongTo(Catagory parentCatagory)
 {
     this.Parent = parentCatagory;
     this.ParentID = parentCatagory.ID;
 }
Пример #8
0
 public void AddChildCatagory(Catagory catagory)
 {
     catagory.FullName = this.FullName + "-" + catagory.Name;
     this.Children.Add(catagory);
 }