Esempio n. 1
0
        public ActionResult DoSave(/*int id, */ CategoryStructureViewModel vm, CategoryStructure newItem)
        {
            try
            {
                //var db = new OnBalance.Models.CategoryStructureRepository();
                //var dbProduct = new ProductRepository();
                //Category model = dbProduct.GetCategory(id);
                //string newName = Request["NewName"];
                //bool isNewApproved = false;

                //InfoFormat("User #{0} updates Category #{1} to name: {2}, status: {3} ({4}), organization: #{5}", User.Identity.Name, vm.Category.Id, vm.Category.Name, vm.Category.StatusName, vm.Category.StatusId, vm.Category.OrganizationId);
                //InfoFormat("User #{0} updates Category #{1} to name: {2}, status: {3} ({4}), organization: #{5}", User.Identity.Name, model.Id, model.Name, model.StatusName, model.StatusId, model.OrganizationId);
                _productRepository.Save(vm.Category);
                //UpdateModel<Category>(model, "Category__");
                //dbProduct.SubmitChanges();

                //if(CategoryStructure != null)
                //{
                Info("Updating category structure...");
                foreach (var item in vm.CategoryStructure)
                {
                    InfoFormat("  Category structure: #{0, -8}. {1}", item.Id, item.FieldName);
                    _repository.Update(item);
                }
                //}

                _repository.Add(newItem);

/*
 *              if(string.IsNullOrEmpty(newName) == false)
 *              {
 *                  bool.TryParse(Request["NewStatus"], out isNewApproved);
 *                  CategoryStructure cs = new CategoryStructure();
 *                  cs.FieldName = newName;
 *                  cs.StatusId = isNewApproved ? (byte)Status.Approved : (byte)Status.Deleted;
 *                  cs.CategoryId = vm.Category.Id;
 *                  db.Add(cs);
 *              }
 */
                _repository.SubmitChanges();

                return(PartialView("CategoryStructure", vm.Category));
            } catch (Exception ex)
            {
                Error("Error updating Category structure!", ex);
                throw ex;
            }
        }
Esempio n. 2
0
 public void Update(CategoryStructure item)
 {
     throw new NotImplementedException();
 }
Esempio n. 3
0
 public void Add(CategoryStructure newItem)
 {
     throw new NotImplementedException();
 }