Beispiel #1
0
        public async Task <IActionResult> Edit(string id, [Bind("ShiId,ShiNm,MaxHr,MinHr,ConH1,AddH1,ConH2,AddH2,BltNm,BltDt,LstNm,LstDt,Tim02,OnnTm,OffTm,NigSh,OnnOt")] Tblroster tblroster)
        {
            if (id != tblroster.ShiId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(tblroster);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException dbex)
                {
                    if (!TblrosterExists(tblroster.ShiId))
                    {
                        //return NotFound();
                        Danger(string.Format("<b>Lỗi {0}</b>", "Not Found"), true);
                    }
                    else
                    {
                        Danger(string.Format("<b>Lỗi {0}</b>", dbex.Message + dbex.InnerException), true);
                    }
                    return(View(tblroster));
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(tblroster));
        }
Beispiel #2
0
        public async Task <IActionResult> Create([Bind("ShiId,ShiNm,MaxHr,MinHr,ConH1,AddH1,ConH2,AddH2,BltNm,BltDt,LstNm,LstDt,Tim02,OnnTm,OffTm,NigSh,OnnOt")] Tblroster tblroster)
        {
            if (ModelState.IsValid)
            {
                try {
                    _context.Add(tblroster);
                    await _context.SaveChangesAsync();

                    return(RedirectToAction(nameof(Index)));
                } catch (Exception ex) {
                    Danger(string.Format("<b>Lỗi {0}</b>", ex.Message + ex.InnerException), true);
                }
            }
            return(View(tblroster));
        }
Beispiel #3
0
        // GET: Admin/Tblrosters/Edit/5
        public async Task <IActionResult> Edit(string id)
        {
            var tblroster = new Tblroster();

            try {
                if (id == null)
                {
                    return(NotFound());
                }

                tblroster = await _context.Tblroster.FindAsync(id);

                if (tblroster == null)
                {
                    return(NotFound());
                }
            } catch (Exception ex) {
                Danger(string.Format("<b>Lỗi {0}</b>", ex.Message + ex.InnerException), true);
            }
            return(View(tblroster));
        }