コード例 #1
0
 public void AddAvatarToUser(Photo photo, string  email)
 {
     photo.User = userService.GetUserByEmail(email);
     AddPhoto(photo);
     photo.User.UserPhotoId = photo.PhotoId;
     uow.Commit();
 }
コード例 #2
0
 public void UpdatePhoto(Photo photo)
 {
     context.Entry(photo).State = EntityState.Modified;
 }
コード例 #3
0
 public void DeletePhoto(Photo photo)
 {
     context.Set<Photo>().Remove(photo);
 }
コード例 #4
0
 public void AddPhoto(Photo photo)
 {
     context.Set<Photo>().Add(photo);
 }
コード例 #5
0
 public void UpdatePhoto(Photo photo)
 {
     photoRepository.UpdatePhoto(photo);
     uow.Commit();
 }
コード例 #6
0
 public void DeletePhoto(Photo photo)
 {
     photoRepository.DeletePhoto(photo);
     uow.Commit();
 }
コード例 #7
0
 public void AddPhoto(Photo photo)
 {
     photoRepository.AddPhoto(photo);
     uow.Commit();
 }
コード例 #8
0
        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");
        }