예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("ID,TableID,TableName,FieldID,FieldName,Detail")] DetailTableERP detailTableERP)
        {
            if (id != detailTableERP.ID)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(detailTableERP);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DetailTableERPExists(detailTableERP.ID))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(detailTableERP));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("ID,TableID,TableName,FieldID,FieldName,Detail")] DetailTableERP detailTableERP)
        {
            if (ModelState.IsValid)
            {
                _context.Add(detailTableERP);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(detailTableERP));
        }
예제 #3
0
        public IActionResult Post(string values)
        {
            /*Check Session */
            var page            = "218";
            var typeofuser      = "";
            var PermisionAction = "";

            // CheckSession
            if (string.IsNullOrEmpty(HttpContext.Session.GetString("Username")))
            {
                Alert("กรุณา Login เข้าสู่ระบบ", NotificationType.error);
                return(RedirectToAction("Login", "Accounts"));
            }
            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 */



            var detailTableERP = new DetailTableERP();

            JsonConvert.PopulateObject(values, detailTableERP);

            if (!TryValidateModel(detailTableERP))
            {
                return(BadRequest());
            }

            _context.DetailTableERPs.Add(detailTableERP);
            _context.SaveChanges();

            return(Ok());
        }