public async Task <ActionResult> DeleteConfirmed(int?empNo, int?salary1)
        {
            Expression <Func <Salary, bool> > salaryPred = s => (s.EmpNo == empNo && s.Salary1 == salary1);
            var salary = _salaryService.FindSalary(salaryPred).Result.FirstOrDefault();

            try
            {
                if (salary == null)
                {
                    return(RedirectToAction("Error", "Home"));
                }
                await _salaryService.DeleteSalary(salary);

                return(RedirectToAction("Index"));
            }
            catch (Exception ex)
            {
                if (ex.InnerException != null)
                {
                    int    index   = ex.InnerException.Message.IndexOf("fails");
                    string message = ex.InnerException.Message;
                    if (index > 0)
                    {
                        message = message.Substring(0, index - 1);
                    }
                    ModelState.AddModelError("Error", "There was an error during: " + message);
                }
                else
                {
                    ModelState.AddModelError("Error", "There was an error during: " + ex.ToString());
                }

                return(View(salary));
            }
        }
Ejemplo n.º 2
0
        public ActionResult DeleteConfirmed(int id)
        {
            _salaryService.DeleteSalary(id);

            return(Content(Url.Action("Index")));
        }
 public void Delete(int id)
 {
     _SalaryService.DeleteSalary(id);
 }