Exemple #1
0
        public async Task <IActionResult> OnGetAsync(int?id)
        {
            if (id == null)
            {
                return(NotFound());
            }

            CostCentre = await _context.CostCentre.FirstOrDefaultAsync(m => m.CostCentreID == id);

            if (CostCentre == null)
            {
                return(NotFound());
            }
            return(Page());
        }
Exemple #2
0
        public async Task <IActionResult> OnDeleteDelete([FromBody] CicotiWebApp.Models.CostCentre obj)
        {
            if (obj != null && HttpContext.User.IsInRole("Admin"))
            {
                try
                {
                    _context.CostCentre.Remove(obj);
                    await _context.SaveChangesAsync();

                    return(new JsonResult("Cost Centre removed successfully"));
                }
                catch (DbUpdateException d)
                {
                    return(new JsonResult("Cost Centre not removed." + d.InnerException.Message));
                }
            }
            else
            {
                return(new JsonResult("Cost Centre not removed."));
            }
        }