Exemple #1
0
        public async Task <IActionResult> Create([Bind("BurialSquareId,BurialLocationNs,BurialLocationEw,LowPairNs,HighPairNs,LowPairEw,HighPairEw")] BurialSquare burialSquare)
        {
            string strLowNS  = burialSquare.LowPairNs.ToString();
            string strHighNS = burialSquare.HighPairNs.ToString();
            string strLowEW  = burialSquare.LowPairEw.ToString();
            string strHighEW = burialSquare.HighPairEw.ToString();


            burialSquare.BurialSquareId = burialSquare.BurialLocationNs + " " + strLowNS + "/" + strHighNS + " " + burialSquare.BurialLocationEw + " " + strLowEW + "/" + strHighEW;

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

                return(RedirectToAction(nameof(Index)));
            }

            var role = (mummyContext.UserRoles
                        .Where(r => r.UserId == userManager.GetUserId(User))
                        .FirstOrDefault());

            if (!(role is null))
            {
                ViewBag.Role = Int32.Parse(role.RoleId);
            }
            return(View(burialSquare));
        }
Exemple #2
0
        public async Task <IActionResult> Edit(string id, [Bind("BurialSquareId,BurialLocationNs,BurialLocationEw,LowPairNs,HighPairNs,LowPairEw,HighPairEw")] BurialSquare burialSquare)
        {
            id = id.Replace("F", "/");
            burialSquare.BurialSquareId = burialSquare.BurialSquareId.Replace("F", "/");


            if (id != burialSquare.BurialSquareId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(burialSquare);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!BurialSquareExists(burialSquare.BurialSquareId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }

            var role = (mummyContext.UserRoles
                        .Where(r => r.UserId == userManager.GetUserId(User))
                        .FirstOrDefault());

            if (!(role is null))
            {
                ViewBag.Role = Int32.Parse(role.RoleId);
            }
            return(View(burialSquare));
        }