Example #1
0
 public void UpdateEmployee(Employee employee)
 {
     using (var dbContext = new PortfolioProjectContext())
     {
         dbContext.Entry(employee).State = EntityState.Modified;
         dbContext.SaveChanges();
     }
 }
Example #2
0
        public HttpStatusCode UpdateEmployee(Employee employee)
        {
            using (var dbContext = new PortfolioProjectContext())
            {
                if (employee != null)
                {
                    try
                    {
                        dbContext.Entry(employee).State = EntityState.Modified;
                        dbContext.SaveChanges();
                    }
                    catch
                    {
                        return(HttpStatusCode.InternalServerError);
                    }
                }
                else
                {
                    return(HttpStatusCode.NotFound);
                }
            }

            return(HttpStatusCode.OK);
        }