Ejemplo n.º 1
0
        public ActionResult Edit(Rp3.Test.Mvc.Models.CategoryEditModel editModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(editModel));
            }

            Rp3.Test.Proxies.Proxy proxy = new Proxies.Proxy();

            Rp3.Test.Common.Models.Category commonModel = new Common.Models.Category();

            commonModel.Active     = editModel.Active;
            commonModel.CategoryId = editModel.CategoryId;
            commonModel.Name       = editModel.Name;

            bool respondeOk = proxy.UpdateCategory(commonModel);

            if (respondeOk)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(editModel));
            }
        }
Ejemplo n.º 2
0
        public ActionResult Create(Rp3.Test.Mvc.Models.CategoryCreateModel createModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(createModel));
            }

            Rp3.Test.Proxies.Proxy proxy = new Proxies.Proxy();

            Rp3.Test.Common.Models.Category commonModel = new Common.Models.Category();

            commonModel.Active = true;
            commonModel.Name   = createModel.Name;

            bool respondeOk = proxy.InsertCategory(commonModel);

            if (respondeOk)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(View(createModel));
            }
        }
Ejemplo n.º 3
0
        public IHttpActionResult GetById(int categoryId)
        {
            Rp3.Test.Common.Models.Category commonModel = null;
            using (DataService service = new DataService())
            {
                var model = service.Categories.GetByID(categoryId);

                commonModel = new Common.Models.Category()
                {
                    Active     = model.Active,
                    CategoryId = model.CategoryId,
                    Name       = model.Name
                };
            }
            return(Ok(commonModel));
        }
Ejemplo n.º 4
0
 public List <Common.Models.Category> GetCategories()
 {
     try
     {
         var dal          = new QuickKartRepository();
         var categoryList = dal.GetCategoriesUsingLinq();
         var categories   = new List <Common.Models.Category>();
         if (categoryList.Any())
         {
             foreach (var cat in categoryList)
             {
                 var category = new Common.Models.Category();
                 category.CategoryId   = cat.CategoryId;
                 category.CategoryName = cat.CategoryName;
                 categories.Add(category);
             }
         }
         return(categories);
     }
     catch (Exception ex)
     {
         return(null);
     }
 }