Ejemplo n.º 1
0
 public ModuleViewModel(Module m, int level)
 {
     Id = m.Id;
     this.ModuleName = m.ModuleName;
     this.Level = level;
     //this.Space = "".PadLeft(m.lvl, ' ');
     this.Space = "".PadLeft(Level, ' ');
 }
Ejemplo n.º 2
0
        public virtual ActionResult CreateModule(string moduleName, string parentModule)
        {
            JsonResponse response = new JsonResponse();

            if (string.IsNullOrEmpty(moduleName))
            {
                response.Success = false;
                response.Message = "You must enter a module name.";
                response.CssClass = "red";

                return Json(response);
            }

            try
            {
                Module a = new Module();
                a.Id = Guid.NewGuid();
                a.ModuleName = moduleName;
                if(!string.IsNullOrWhiteSpace(parentModule))
                    a.ParentModule = parentModule;
                moduleRepo.Create(a);

                if (Request.IsAjaxRequest())
                {
                    response.Success = true;
                    response.Message = "Module created successfully!";
                    response.CssClass = "green";

                    return Json(response);
                }

                return RedirectToAction("Index");
            }
            catch (Exception ex)
            {
                if (Request.IsAjaxRequest())
                {
                    response.Success = false;
                    response.Message = ex.InnerException.Message;
                    response.CssClass = "red";

                    return Json(response);
                }

                ModelState.AddModelError("", ex.InnerException.Message);
            }

            return RedirectToAction("Index");
        }
Ejemplo n.º 3
0
 public void Create(Module module)
 {
     context.Modules.Add(module);
     context.SaveChanges();
 }