// PUT api/Enterprise/5
        public HttpResponseMessage PutEmployee(int id, Employee employee)
        {
            if (!ModelState.IsValid)
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }

            if (id != employee.EmployeeId)
            {
                return Request.CreateResponse(HttpStatusCode.BadRequest);
            }

            db.Entry(employee).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException ex)
            {
                return Request.CreateErrorResponse(HttpStatusCode.NotFound, ex);
            }

            return Request.CreateResponse(HttpStatusCode.OK);
        }
 public ActionResult Edit(Employee employee)
 {
     if (ModelState.IsValid)
     {
         db.Entry(employee).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     ViewBag.MaritalStatusID = new SelectList(db.MaritalStatus, "MaritalStatusId", "Status", employee.MaritalStatusID);
     ViewBag.PositionID = new SelectList(db.Positions, "PositionId", "Name", employee.PositionID);
     return View(employee);
 }
        // POST api/Enterprise
        public HttpResponseMessage PostEmployee(Employee employee)
        {
            if (ModelState.IsValid)
            {
                db.Employees.Add(employee);
                db.SaveChanges();

                HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Created, employee);
                response.Headers.Location = new Uri(Url.Link("DefaultApi", new { id = employee.EmployeeId }));
                return response;
            }
            else
            {
                return Request.CreateErrorResponse(HttpStatusCode.BadRequest, ModelState);
            }
        }
        public ActionResult Logon(Employee user)
        {
            var employee = db.Employees.FirstOrDefault(s => s.UserName.Contains(user.UserName)
                && s.Password.Contains(user.Password));

            if (employee != null)
            {
                Session.Add("user", employee.EmployeeId);
                Session.Add("name", employee.FullName);
                return RedirectToAction("Profile");
            }
            else
            {
                ViewBag.Error = "Ім'я користувача або пароль вказані невірно!";
                return View();
            }
        }