Пример #1
0
        public IHttpActionResult PostCategory(Category category)
        {
            if (!ModelState.IsValid)
            {
                return BadRequest(ModelState);
            }

            db.Categories.Add(category);
            db.SaveChanges();

            return CreatedAtRoute("DefaultApi", new { id = category.Id }, category);
        }
Пример #2
0
 public CategoriesViewModel(Category category)
 {
     this.Id = category.Id;
     this.Name = category.Name;
     this.Approved = category.Approved;
     if (category.Name == "All Categories")
     {
         this.CouponsNumber = db.Coupons.Where(x => x.IsEdited == false && x.IsDeleted == false && x.Acitve == true && x.Approved == true).ToList().Count;
     }
     else
     {
         this.CouponsNumber = db.Coupons.Where(x => x.CategoryId == category.Id && x.IsEdited == false && x.IsDeleted == false && x.Acitve == true && x.Approved == true).ToList().Count;
     }
 }