public ActionResult Delete(int id, Project project)
 {
     try
     {
         Facade.GetProjectGateway().Delete(id);
         return RedirectToAction("Index");
     }
     catch
     {
         return View();
     }
 }
        public ActionResult Create(ProjectViewModel project)
        {
            ProjectWithDepartmentViewModel view = new ProjectWithDepartmentViewModel();
            view.Departments = Facade.GetDepartmentGateway().ReadAll();
            view.Project = project;

            if (project.Image.ContentLength > (2 * 1024 * 1024))
            {
                ModelState.AddModelError("CustomError", "Filen skal være mindre end 2 MB");
                return View(view);
            }

            if (!(project.Image.ContentType == "image/jpeg" || project.Image.ContentType == "image/gif"))
            {
                ModelState.AddModelError("CustomError", "Tillate fil typer jpeg og gif");
                return View(view);
            }

            if (ModelState.IsValid)
            {
                byte[] data = new byte[project.Image.ContentLength];
                project.Image.InputStream.Read(data, 0, project.Image.ContentLength);

                project.ImageData = data;

                Project newProject = new Project()
                {
                    Name = project.Name,
                    ImageData = project.ImageData,
                    DepartmentId = project.DepartmentId
                };

                Facade.GetProjectGateway().Create(newProject);
                return RedirectToAction("Index");
            }

            return View(view);
        }
 public ActionResult Edit(Project project)
 {
     if (ModelState.IsValid)
     {
         Facade.GetProjectGateway().Update(project);
         return RedirectToAction("Index");
     }
     return View(project);
 }