public async Task <ActionResult> Edit(Guid?id)
        {
            Permission p    = new Permission();
            bool       auth = p.IsGranted(User.Identity.Name, this.ControllerContext.RouteData.Values["controller"].ToString() + "_" + this.ControllerContext.RouteData.Values["action"].ToString());

            if (!auth)
            {
                return(new ViewResult()
                {
                    ViewName = "Unauthorized"
                });
            }
            else
            {
                if (id == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                LessonTypesModels lessonTypesModels = await db.LessonTypes.FindAsync(id);

                if (lessonTypesModels == null)
                {
                    return(HttpNotFound());
                }
                return(View(lessonTypesModels));
            }
        }
        public async Task <ActionResult> Create([Bind(Include = "Id,Name,Active")] LessonTypesModels lessonTypesModels)
        {
            if (ModelState.IsValid)
            {
                lessonTypesModels.Id     = Guid.NewGuid();
                lessonTypesModels.Active = true;
                db.LessonTypes.Add(lessonTypesModels);

                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(lessonTypesModels));
        }
        public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Active")] LessonTypesModels lessonTypesModels)
        {
            if (ModelState.IsValid)
            {
                var current_data = await db.LessonTypes.FindAsync(lessonTypesModels.Id);

                current_data.Name            = lessonTypesModels.Name;
                current_data.Active          = lessonTypesModels.Active;
                db.Entry(current_data).State = EntityState.Modified;
                await db.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }

            return(View(lessonTypesModels));
        }