public void AddAvatarToUser(Photo photo, string  email)
 {
     photo.User = userService.GetUserByEmail(email);
     AddPhoto(photo);
     photo.User.UserPhotoId = photo.PhotoId;
     uow.Commit();
 }
 public void UpdatePhoto(Photo photo)
 {
     context.Entry(photo).State = EntityState.Modified;
 }
 public void DeletePhoto(Photo photo)
 {
     context.Set<Photo>().Remove(photo);
 }
 public void AddPhoto(Photo photo)
 {
     context.Set<Photo>().Add(photo);
 }
 public void UpdatePhoto(Photo photo)
 {
     photoRepository.UpdatePhoto(photo);
     uow.Commit();
 }
 public void DeletePhoto(Photo photo)
 {
     photoRepository.DeletePhoto(photo);
     uow.Commit();
 }
 public void AddPhoto(Photo photo)
 {
     photoRepository.AddPhoto(photo);
     uow.Commit();
 }
        public ActionResult Upload(HttpPostedFileBase image)
        {
            if (image != null && (image.ContentType == "image/jpg" || image.ContentType == "image/png" || image.ContentType == "image/jpeg"))
            {
                var img = new Photo()
                {
                    MimeType = image.ContentType,
                    Data = new byte[image.ContentLength]
                };
                image.InputStream.Read(img.Data, 0, image.ContentLength);
                photoService.AddAvatarToUser(img, User.Identity.Name);

                if (Request.IsAjaxRequest())
                { }
                return RedirectToAction("Index");
            }
            return RedirectToAction("Index");
        }