Esempio n. 1
0
        //
        // POST: /pradmin/dosavestructure

        //[HttpPost]
        public ActionResult DoSaveStructure(int id, CategoryStructureViewModel vm /*FormCollection f, List<CategoryStructure> CategoryStructure*/)
        {
            try
            {
                var db        = new OnBalance.Domain.Entities.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);
                throw new NotImplementedException("dbProduct.Save(vm.Category)");
                //dbProduct.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);
                    throw new NotImplementedException("db.Update(item)");
                    //db.Update(item);
                }
                //}

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

                db.SubmitChanges();

                return(PartialView("CategoryStructure", vm.Category));
            } catch (Exception ex)
            {
                Error("Error updating Category structure!", ex);
                throw ex;
            }
        }
Esempio n. 2
0
        //
        // POST: /pradmin/dosavestructure
        //[HttpPost]
        public ActionResult DoSaveStructure(int id, CategoryStructureViewModel vm /*FormCollection f, List<CategoryStructure> CategoryStructure*/)
        {
            try
            {
                var db = new OnBalance.Domain.Entities.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);
                throw new NotImplementedException("dbProduct.Save(vm.Category)");
                //dbProduct.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);
                        throw new NotImplementedException("db.Update(item)");
                        //db.Update(item);
                    }
                //}

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

                db.SubmitChanges();

                return PartialView("CategoryStructure", vm.Category);
            } catch(Exception ex)
            {
                Error("Error updating Category structure!", ex);
                throw ex;
            }
        }