Пример #1
0
        public async Task <IActionResult> Create([Bind("TypeOfSalaryId,TypeOfSalaryName")] TypeOfSalary typeOfSalary)
        {
            /*Check Session */
            var page            = "120";
            var typeofuser      = "";
            var PermisionAction = "";

            // CheckSession
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username")))
            {
                Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                typeofuser      = HttpContext.Session.GetString("TypeOfUserId");
                PermisionAction = HttpContext.Session.GetString("PermisionAction");
                if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false)
                {
                    Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            /*Check Session */

            if (ModelState.IsValid)
            {
                _context.Add(typeOfSalary);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(typeOfSalary));
        }
Пример #2
0
        public async Task <IActionResult> Edit([Bind("TypeOfSalaryId,TypeOfSalaryName")] TypeOfSalary typeOfSalary)
        {
            /*Check Session */
            var page            = "122";
            var typeofuser      = "";
            var PermisionAction = "";

            // CheckSession
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username")))
            {
                Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                return(RedirectToAction("Index", "Home"));
            }
            else
            {
                typeofuser      = HttpContext.Session.GetString("TypeOfUserId");
                PermisionAction = HttpContext.Session.GetString("PermisionAction");
                if (PermisionHelper.CheckPermision(typeofuser, PermisionAction, page) == false)
                {
                    Alert("คุณไม่มีสิทธิ์ใช้งานหน้าดังกล่าว", NotificationType.error);
                    return(RedirectToAction("Index", "Home"));
                }
            }
            /*Check Session */


            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(typeOfSalary);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TypeOfSalaryExists(typeOfSalary.TypeOfSalaryId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(RedirectToAction("Index", "Home"));
        }