示例#1
0
        public ActionResult UploadFinish(IEnumerable <HttpPostedFileBase> files)
        {
            String message = "";
            String status  = "";

            try
            {
                if (Session["ProneId"] != null)
                {
                    int id = Convert.ToInt32(Session["ProneId"]);
                    foreach (var file in files)
                    {
                        Photo  foto      = new Photo();
                        string fileName  = Path.GetFileNameWithoutExtension(file.FileName);
                        string extension = Path.GetExtension(file.FileName);
                        fileName            = fileName + extension;
                        foto.profilePicPath = "~/Album/" + fileName;
                        fileName            = Path.Combine(Server.MapPath("~/Album/"), fileName);
                        foto.profilePicName = fileName;
                        file.SaveAs(fileName);
                        PhotoDbClient photoDbClient = new PhotoDbClient();
                        photoDbClient.InsertToAlbum(foto, id);
                    }
                    message = "Files uploaded successfully!";
                    status  = "success";
                }
            }
            catch (Exception ex)
            {
                status  = "failed";
                message = "Something went wrong! " + ex.Message;
            }


            return(Json(new { data = new { status = status, message = message } }));
        }
        public ActionResult MoreInfo(FormCollection collection)
        {
            ViewBag.Images   = null;
            ViewBag.Comments = null;
            int id = Convert.ToInt32(collection["propertyTxt"]);

            try
            {
                ProneDbClient   dbClient        = new ProneDbClient();
                PhotoDbClient   fotoDbClient    = new PhotoDbClient();
                CommentDbClient commentDbClient = new CommentDbClient();
                try
                {
                    if (dbClient.Exists(id))
                    {
                        ProneFullInformation fullInfo = dbClient.GetProneById(id);
                        ViewBag.Information = fullInfo;
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "Nothing found in the database!";
                    }
                }
                catch (NullReferenceException ex)
                {
                    ViewBag.ErrorMessage = "Something went wrong! " + ex.Message;
                }

                try
                {
                    if (dbClient.Exists(id))
                    {
                        ViewBag.Images = fotoDbClient.SelectAlbum(id);
                    }
                }
                catch (NullReferenceException ex)
                {
                    ViewBag.ErrorMessage = "Something went wrong! " + ex.Message;
                    ViewBag.Status       = "false";
                }


                try
                {
                    if (dbClient.Exists(id))
                    {
                        ViewBag.Comments = commentDbClient.GetCommentsByProperty(id);
                    }
                }
                catch (NullReferenceException ex)
                {
                    ViewBag.ErrorMessage = "Something went wrong! " + ex.Message;
                    ViewBag.Status       = "false";
                }
            }
            catch (SqlException ex)
            {
                ViewBag.ErrorMessage = "Something went wrong! " + ex.Message;
            }



            return(View());
        }