public ActionResult Candidate(CandidateViewModel model, HttpPostedFileBase uploadImage)
 {
     if (UserDAL.GetUserByName(User.Identity.Name).Candidate != null)
     {
         return(RedirectToAction("Index", "Home"));
     }
     if (ModelState.IsValid)
     {
         byte[] imageData = null;
         if (uploadImage != null)
         {
             using (var binaryReader = new BinaryReader(uploadImage.InputStream))
             {
                 imageData = binaryReader.ReadBytes(uploadImage.ContentLength);
             }
         }
         if (CandidateDAL.Create(new Candidate {
             FullName = model.FullName, Birthday = model.Birthday, KeyWords = model.KeyWords, Photo = imageData, UserId = UserDAL.GetUserByName(User.Identity.Name), WorkExpirience = model.WorkExpirience
         }))
         {
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError(string.Empty, "Что-то пошло не так, попробуйте ещё раз");
         }
     }
     else
     {
         ModelState.AddModelError(string.Empty, "Registration failed.");
     }
     return(View());
 }