Ejemplo n.º 1
0
        //Updates the existing Driver Details
        public async Task <IActionResult> OnPutUpdateAmtPrin([FromBody] Models.ActCostAccountAmtPrinciple obj)
        {
            if (obj != null && (HttpContext.User.IsInRole("Admin")))
            {
                try
                {
                    _context.Attach(obj).State = EntityState.Modified;
                    await _context.SaveChangesAsync();

                    return(new JsonResult(obj));
                }
                catch (DbUpdateException d)
                {
                    return(new JsonResult("Amt Per Principle not saved." + d.InnerException.Message));
                }
            }
            return(new JsonResult("Amt Per Principle saved."));
        }
Ejemplo n.º 2
0
        //Inserts a new Employee with details
        public async Task <IActionResult> OnPostInsertAmtPrin([FromBody] Models.ActCostAccountAmtPrinciple obj)
        {
            if (obj != null && (HttpContext.User.IsInRole("Admin") || HttpContext.User.IsInRole("Fleet")))
            {
                try
                {
                    _context.Add(obj);
                    await _context.SaveChangesAsync();

                    int id = obj.ActCostAccountAmtPrincipleID; // Yes it's here
                    return(new JsonResult(obj));
                }
                catch (DbUpdateException d)
                {
                    return(new JsonResult("Amt Principle Not Added." + d.InnerException.Message));
                }
            }

            else
            {
                return(new JsonResult("Amt Principle Not Inserted"));
            }
        }