コード例 #1
0
 public IEnumerable <Classes.Area> getAreas()
 {
     using (var c = new SistemaAcademico.DataModel.AcademicSystemContext())
     {
         return(c.Areas.ToList());
     }
 }
コード例 #2
0
 public HttpResponseMessage createArea(AreaDTO data)
 {
     using (var c = new SistemaAcademico.DataModel.AcademicSystemContext())
     {
         c.Areas.Add(new Classes.Area
         {
             Name   = data.Name,
             Codigo = data.Codigo
         });
         c.SaveChanges();
         return(Request.CreateResponse(HttpStatusCode.Created));
     }
 }
コード例 #3
0
 public HttpResponseMessage UpdateArea(AreaDTO data)
 {
     using (var c = new SistemaAcademico.DataModel.AcademicSystemContext())
     {
         var inDB = c.Areas.Where(a => a.AreaID == data.areaID).FirstOrDefault();
         if (inDB != null)
         {
             inDB.Codigo = data.Codigo;
             inDB.Name   = data.Name;
             c.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.Created));
         }
         return(Request.CreateResponse(HttpStatusCode.NotFound));
     }
 }
コード例 #4
0
        public ActionResult Index()
        {
            string identity = null;
            string userName = System.Threading.Thread.CurrentPrincipal.Identity.Name;

            try
            {
                identity = Request.Cookies["appUser"].Value;
            }
            catch (Exception) { return(View("~/Views/Login/Index.cshtml")); };

            using (var context = new SistemaAcademico.DataModel.AcademicSystemContext())
            {
                ViewModels.IndexViewModel Model       = new ViewModels.IndexViewModel();
                List <MenuOptionsDTO>     MenuResults = new List <MenuOptionsDTO>();
                var curser_email = identity.Split(',')[0];
                var currentUser  = context.Usuarios.Where(u => u.Email == curser_email).FirstOrDefault();
                var source       = context.OpcionesDelMenu
                                   .Where(o => o.parent == null && o.allowedType == currentUser.UserType)
                                   .OrderBy(o => o.order)
                                   .ToList();
                foreach (MenuOption Opcion in source)
                {
                    MenuResults.Add(new MenuOptionsDTO
                    {
                        OpcionDeMenu = Opcion,
                        Childs       = context.OpcionesDelMenu
                                       .Where(child => child.parent.id == Opcion.id)
                                       .OrderBy(o => o.order)
                                       .ToList()
                    });
                }
                Model.OpcionesDeMenu = MenuResults;

                return(View(Model));
            }
        }