Esempio n. 1
0
        public ActionResult Save(AuctionInventoryDAL.Entity.Employee emp)
        {
            bool status = false;

            try
            {
                if (ModelState.IsValid)
                {
                    EmployeeRepository employeeRepository = new EmployeeRepository();
                    if (emp == null)
                    {
                        ModelState.AddModelError("error", "Record Can not be null");
                    }
                    status = employeeRepository.SaveEdit(emp);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("error", "Something Went Wrong!");
                status = false;
                throw e;
            }

            return(new JsonResult {
                Data = new { status = status }
            });
        }
        public bool SaveEdit(AuctionInventoryDAL.Entity.Employee employee)
        {
            bool status = false;

            if (employee.EmployeeID > 0)
            {
                //Edit Existing Record
                var v = auctionContext.Employees.Where(a => a.EmployeeID == employee.EmployeeID).FirstOrDefault();
                if (v != null)
                {
                    v.FirstName = employee.FirstName;
                    v.LastName  = employee.LastName;
                    v.EmailID   = employee.EmailID;
                    v.City      = employee.City;
                    v.Country   = employee.Country;
                }
            }
            else
            {
                //Save
                auctionContext.Employees.Add(employee);
            }
            auctionContext.SaveChanges();
            status = true;
            return(status);
        }
Esempio n. 3
0
 public ActionResult Save(int id)
 {
     AuctionInventoryDAL.Entity.Employee employee = new AuctionInventoryDAL.Entity.Employee();
     try
     {
         if (ModelState.IsValid)
         {
             EmployeeRepository employeeRepository = new EmployeeRepository();
             if (employee == null)
             {
                 ModelState.AddModelError("error", "No Record Found");
             }
             employee = employeeRepository.Get(id);
         }
     }
     catch (Exception e)
     {
         ModelState.AddModelError("error", "Something Went Wrong!");
         employee = null;
         throw e;
     }
     return(View(employee));
 }