Example #1
0
        public ActionResult SignIn(UserModel user)
        {
            if (ModelState.IsValid)
            {
                DBManager dbm = new DBManager();

                if (dbm.UserManager.IsTheEmailInTheDB(user.UserEmail))
                {
                    return(View());
                }

                ConvalidationUser cu = new ConvalidationUser(user);
                if (!cu.isTheUserHaveValidParametres())
                {
                    return(View());
                }

                AsyncFunctionToUse.SendMailForConvalidation(user);

                // Log
                LogMaster.WriteOnLog("a new user have signin with username " + user.UserName);

                return(Content("Abbiamo inviato un'email di conferma"));
            }

            return(View());
        }
        public ActionResult DeletePhoto(string photoOS, string photoP)
        {
            List <string> photosToRemove = new List <string> {
                photoOS, photoP
            };

            AsyncFunctionToUse.RemoveImages((string)Session["user_id"], photosToRemove);

            return(RedirectToAction("Gallery", "Gallery"));
        }
        public ActionResult Upload(HttpPostedFileBase file)
        {
            if (file != null && file.ContentType.Contains("image"))
            {
                if (file.ContentLength > 5000000)
                {
                    return(RedirectToAction("UploadPhoto", "Home", new { msg = "The file is too big, max 5 MB" }));
                }

                // Log
                LogMaster.WriteOnLog("user " + (string)Session["user_id"] + " uploaded an image with name " + file.FileName);

                AsyncFunctionToUse.UploadPhoto(file, (string)Session["user_id"]);

                return(RedirectToAction("UploadPhoto", "Home", new { msg = "Uploaded with success" }));
            }

            return(RedirectToAction("UploadPhoto", "Home", new { msg = "Wrong file content type" }));
        }
        public ActionResult DeletePhotos(Dictionary <string, bool> _PhotosToDelete)
        {
            List <string> photoToDelete = new List <string>();

            foreach (KeyValuePair <string, bool> photo in _PhotosToDelete)
            {
                if (photo.Value == true)
                {
                    photoToDelete.Add(photo.Key);

                    // Add the photoPreview for be delete
                    int indexOfPoint = photo.Key.IndexOf('.');
                    photoToDelete.Add(photo.Key.Insert(indexOfPoint, "_Preview"));
                }
            }

            AsyncFunctionToUse.RemoveImages((string)Session["user_id"], photoToDelete);

            return(RedirectToAction("Gallery", "Gallery"));
        }
        private void ClearUserData()
        {
            DBManager    dbm           = new DBManager();
            List <Photo> allUserPhotos = dbm.PhotoManager.GetPhotosOfUser((string)Session["user_id"]);

            List <string> photoToDelete = new List <string>();

            foreach (Photo photo in allUserPhotos)
            {
                photoToDelete.Add(photo.PhotoNameOriginalSize);
                photoToDelete.Add(photo.PhotoNamePreview);
            }

            AsyncFunctionToUse.RemoveImages((string)Session["user_id"], photoToDelete);

            ConnectionBS cbs = new ConnectionBS((string)Session["user_id"]);

            cbs.UserBSManager.DeleteUserContainer();

            dbm.UserManager.DeleteUserFromDB((string)Session["user_id"]);
        }