Ejemplo n.º 1
0
 public ActionResult Index(Net.Models.User user, Net.Models.File file)
 {
     try
     {
         BL.User bluser = new BL.User();
         bluser.Insert(user, file);
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View(user));
     }
 }
Ejemplo n.º 2
0
        public ActionResult AddArtwork(UserGalleryArtworkFile ugfa)
        {
            if (Authenticate.IsAuthenticated())
            {
                BL.Gallery galleryHelper = new BL.Gallery();


                ugfa.User = (Net.Models.User)Session["user"];
                Net.Models.User user = ugfa.User;
                ugfa.Galleries = galleryHelper.LoadByUserId(user.Id);

                return View(ugfa);
            }
            else
            {
                return RedirectToAction("Login", "Login", new { returnurl = HttpContext.Request.Url });
            }
        }
Ejemplo n.º 3
0
 public ActionResult ImageUpload(Net.Models.File file, Net.Models.User user, UserGalleryArtworkFile ugaf)
 {
     try
     {
         ugaf.User = (Net.Models.User)Session["user"];
         user = ugaf.User;
         user.Files.Add(file);
         BL.File fileHelper = new BL.File();
         file.UserId = user.Id;
         file.FileName = user.UserName + "-Avatar";
         fileHelper.Insert(file);
         return RedirectToAction("Index");
     }
     catch (Exception)
     {
         return View(ugaf);
     }
 }
Ejemplo n.º 4
0
 public ActionResult GalleryAdd(UserGalleryArtworkFile ugfa, Net.Models.Gallery gallery)
 {
     try
     {
         ugfa.User = (Net.Models.User)Session["user"];
         Net.Models.User user = ugfa.User;
         BL.Gallery galleryHelper = new BL.Gallery();
         Net.Models.Gallery newGallery = new Net.Models.Gallery();
         newGallery.UserId = ugfa.User.Id;
         newGallery.GalleryDescription = gallery.GalleryDescription;
         newGallery.GalleryName = gallery.GalleryName;
         newGallery.DateCreated = DateTime.UtcNow;
         galleryHelper.Insert(newGallery);
         return View(ugfa);
     }
     catch (Exception)
     {
         return View();
     }
 }
Ejemplo n.º 5
0
 public ActionResult GalleryAdd(UserGalleryArtworkFile ugfa)
 {
     if (Authenticate.IsAuthenticated())
     {
         try
         {
             ugfa.User = (Net.Models.User)Session["user"];
             Net.Models.User user = ugfa.User;
             return View(ugfa);
         }
         catch (Exception ex)
         {
             ViewBag.Message = ex.Message;
             return View();
         }
     }
     else
     {
         return RedirectToAction("Login", "Login", new { returnurl = HttpContext.Request.Url });
     }
 }
Ejemplo n.º 6
0
        public ActionResult Login(Net.Models.User user, string returnurl)
        {
            ViewResult result = View(user);

            try
            {
                ViewBag.ReturnUrl = returnurl;
                BL.User blUser = new BL.User();

                //ViewBag.ReturnUrl = returnUrl;
                if (blUser.Login(user.UserName, user.Password))
                {
                    BL.User useree = new BL.User();
                    user = useree.LoadByUsername(user.UserName);

                    HttpContext.Session["user"] = user;
                    //return result;
                    if (!string.IsNullOrEmpty(returnurl))
                    {
                        return(Redirect(returnurl));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "Profile"));
                    }
                }
                ViewBag.Message = "Login Failed";

                return(result);
            }
            catch (Exception ex)
            {
                ViewBag.Message = ex.Message;
                return(View(user));
            }
        }
Ejemplo n.º 7
0
        public ActionResult Edit(UserGalleryArtworkFile ugaf, Net.Models.File file, HttpPostedFileBase upload)
        {
            if (ModelState.IsValid)
            {
                //ugaf.User = (Net.Models.User)Session["user"];
                Net.Models.User user = (Net.Models.User)Session["user"];
                BL.User userHelper = new BL.User();
                BL.File fileHelper = new BL.File();
                BL.Artwork artworkHelper = new BL.Artwork();

                var oldFile = fileHelper.LoadByUserId(user.Id);
                Net.Models.File existingFile = new Net.Models.File();


                Net.Models.User newUser = userHelper.LoadById(user.Id);

                using (userHelper = new BL.User())
                {
                    newUser.FirstName = ugaf.User.FirstName;
                    newUser.LastName = ugaf.User.LastName;
                    newUser.Password = ugaf.User.Password;
                    newUser.CommissionActive = ugaf.User.CommissionActive;
                }

                foreach (var f in oldFile)
                {
                    existingFile.ArtworkId = f.ArtworkId;
                    existingFile.Content = f.Content;
                    existingFile.ContentType = f.ContentType;
                    existingFile.FileName = f.FileName;
                    existingFile.FileType = f.FileType;
                    existingFile.Id = f.Id;
                    existingFile.UserId = f.UserId;
                    existingFile.Artwork = artworkHelper.LoadById(f.ArtworkId);
                    existingFile.User = newUser;
                }

                try
                {
                    if (upload != null && upload.ContentLength > 0)
                    {
                        file = new Net.Models.File
                        {
                            Id = existingFile.Id,
                            FileName = System.IO.Path.GetFileName(upload.FileName),
                            FileType = FileType.Avatar,
                            ContentType = upload.ContentType,
                            Content = existingFile.Content,
                            Artwork = existingFile.Artwork,
                            User = existingFile.User,
                            UserId = existingFile.UserId,
                            ArtworkId = existingFile.ArtworkId
                        };
                        using (var reader = new System.IO.BinaryReader(upload.InputStream))
                        {
                            file.Content = reader.ReadBytes(upload.ContentLength);
                        }

                        System.Diagnostics.Debug.WriteLine(newUser.Id);
                        System.Diagnostics.Debug.WriteLine(file.FileName);
                        ugaf.User.Files = new List<Net.Models.File> { file };
                        userHelper.Update(newUser, file);
                    }
                    else
                    {
                        ugaf.User = newUser;
                        userHelper.Update(newUser, existingFile);
                    }

                    return RedirectToAction("Index");
                }
                catch (Exception ex)
                {
                    ViewBag.Message = ex.Message;
                    return View(ugaf);
                }
            }
            return View();
        }
Ejemplo n.º 8
0
 // GET: Join
 public ActionResult Index()
 {
     Net.Models.User user = new Net.Models.User();
     return(View(user));
 }