コード例 #1
0
        public ActionResult CreatePROC(int id, Models.ProjectCreatePROCViewModel newPROC)
        {
            ProjectAuth cred = check_clientRelation(id);

            Models.ProjectCreatePROCViewModel createPROC = new Models.ProjectCreatePROCViewModel();
            // TODO: We need to validate this data, some one may POST data that is not good or designed to cause server exceptions.
            createPROC.Investor_ID = cred.Investor_ID;
            createPROC.Project_ID  = id;
            createPROC.Performance_Begin_DateTime = newPROC.Performance_Begin_DateTime;
            createPROC.Performance_End_DateTime   = newPROC.Performance_End_DateTime;
            createPROC.Revenue_Percentage         = newPROC.Revenue_Percentage;
            if (newPROC.Investment_Amount > createPROC.Financial_Account_Balance)
            {
                ModelState.AddModelError("Not_Enough_Funds", string.Format("You lack sufficient funds: ${0} ", (newPROC.Investment_Amount - createPROC.Financial_Account_Balance)));
                return(View(createPROC));
            }
            else
            {
                createPROC.Investment_Amount = newPROC.Investment_Amount;
            }
            int newPROC_id = 0;

            if (!cred.Valid) // this will fire if you are not the project owner.
            {
                newPROC_id = createPROC.create_PROC();
            }
            else
            {
                return(Redirect("/User/Index")); // TODO: do something else but this is good enough for now, if they are not authenticated this will kick the client all the way back to the home screen.
            }
            return(Redirect(string.Format("/PROC/Details/{0}", newPROC_id)));
        }
コード例 #2
0
 public ActionResult Details(int id)
 {
     Models.ProjectIndexViewModel projectAccount = new Models.ProjectIndexViewModel(id);
     projectAccount.display_Project_ID = id;
     if (User.Identity.IsAuthenticated)
     {
         projectAccount.IsRegisteredViewer = true;
     }
     else
     {
         projectAccount.IsRegisteredViewer = false;
     }
     projectAccount.get_ProjectData(id);
     if (projectAccount.Profile_Public)
     {
         return(View(projectAccount));
     }
     else
     {
         /// in this way we will display a project profile to the owner of the project in case they want to see what the profile will look like before making it public.
         ProjectAuth cred = check_clientRelation(id);
         projectAccount.IsRegisteredViewer = false; /// do not display a post message field to the project owner.
         if (cred.Valid)
         {
             Models.ProjectIndexViewModel ownerAccount = new Models.ProjectIndexViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
             manageClient_Sessions(cred);
             ownerAccount.display_Project_ID = cred.Project_ID;
             return(View(ownerAccount));
         }
         else /// The client user is not the owner and this project is set to not be viewable.
         {
             return(Redirect("/User/Index")); /// TODO: Replace this redirect to something more helpful, perhpas one of the serach pages once it is built.
         }
     }
 }
コード例 #3
0
        public ActionResult CreatePROC(int id)
        {
            /// Change: Made a change here to instantiate a projectCreatePROCViewModel that accepts the investor account of the person logged in.
            ProjectAuth cred = check_clientRelation(id);

            /// Change:  Used an overloaded version of this object that accepts the investor's account ID to load.
            Models.ProjectCreatePROCViewModel createPROC = new Models.ProjectCreatePROCViewModel(cred.Investor_ID);
            return(View(createPROC));
        }
コード例 #4
0
        public ActionResult UploadImage(int id)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                Redirect("/User/Index/");
            }
            Models.ProjectUploadImageViewModel updateModel = new Models.ProjectUploadImageViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            return(View(updateModel));
        }
コード例 #5
0
        public ActionResult Edit(int id)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectEditViewModel projectModel = new Models.ProjectEditViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, id);
            return(View(projectModel));
        }
コード例 #6
0
        public ActionResult UploadDocument(int id)
        {
            int         project_id = id;
            ProjectAuth cred       = check_clientRelation(project_id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectUploadDocumentViewModel uploadModel = new Models.ProjectUploadDocumentViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            return(View(uploadModel));
        }
コード例 #7
0
        public ActionResult Index(int id)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index")); // relation not valid return to user index screen.
            }
            manageClient_Sessions(cred);
            Models.ProjectIndexViewModel projectModel = new Models.ProjectIndexViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, id);
            return(View(projectModel));
        }
コード例 #8
0
        public ActionResult UploadImage(int id, HttpPostedFileBase upload_Image)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                Redirect("/User/Index/");
            }
            Models.ProjectUploadImageViewModel updateModel = new Models.ProjectUploadImageViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            try
            {
                // code to process a posted image file.
                byte[] picture_bytes = null;
                if (ModelState.IsValid)
                {
                    if (upload_Image != null)
                    {
                        if (upload_Image.ContentLength > 0)
                        {
                            int      MaxContentLength      = 1024 * 1024 * 3;
                            string[] AllowedFileExtensions = new string[] { ".jpg", ".gif", ".png", ".pdf" };

                            if (!AllowedFileExtensions.Contains(upload_Image.FileName.Substring(upload_Image.FileName.LastIndexOf('.'))))
                            {
                                ModelState.AddModelError("upload_Image", "Please only use file types: " + string.Join(", ", AllowedFileExtensions));
                            }
                            else if (upload_Image.ContentLength > MaxContentLength)
                            {
                                ModelState.AddModelError("upload_Image", string.Format("Your file is too large, maximum file size is: {0} Bytes.", MaxContentLength));
                            }
                            else
                            {
                                picture_bytes = new byte[upload_Image.ContentLength];
                                upload_Image.InputStream.Read(picture_bytes, 0, upload_Image.ContentLength);
                            }
                        }
                    }
                }

                updateModel.Profile_Image = picture_bytes;
                updateModel.upload_Image();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(View());
            }
            return(Redirect(string.Format("/Project/Index/{0}", cred.Project_ID)));
        }
コード例 #9
0
        public ActionResult UploadDocument(int id, HttpPostedFileBase upload_Document)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectUploadDocumentViewModel uploadModel = new Models.ProjectUploadDocumentViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            uploadModel.File_Name = upload_Document.FileName;
            uploadModel.Mime_Type = upload_Document.ContentType;
            byte[] hold = new byte[upload_Document.ContentLength];
            upload_Document.InputStream.Read(hold, 0, upload_Document.ContentLength);
            uploadModel.Binary_File = hold;
            uploadModel.upload_file();
            return(Redirect(string.Format("/Project/Details/{0}", id)));
        }
コード例 #10
0
        public ActionResult RemoveImage(int id)
        {
            // In order for this method to be called the client must be logged in as the project owner.
            if (Session["Project_ID"] == null)
            {
                return(Redirect("/User/Index"));
            }
            int         project_id = (int)Session["Project_ID"];
            ProjectAuth cred       = check_clientRelation(project_id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectDeleteImageViewModel modifyModel = new Models.ProjectDeleteImageViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, project_id);
            modifyModel.Image_ID = id;
            modifyModel.get_Image();
            return(View(modifyModel));
        }
コード例 #11
0
        public ActionResult RemoveDocument(int id)
        {
            // This method will need that the user be logged in as a project owner so we can get the project id from session.
            if (Session["Project_ID"] == null)
            {
                return(Redirect("/User/Index"));
            }
            int         project_id = (int)Session["Project_ID"];
            ProjectAuth cred       = check_clientRelation(project_id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectDeleteDocumentViewModel modifyModel = new Models.ProjectDeleteDocumentViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            modifyModel.Document_ID = id;
            modifyModel.get_DocumentName();
            return(View(modifyModel));
        }
コード例 #12
0
        /// <summary>
        /// Private method used to add/update the client's session variable for the project account they are logged in as.
        /// </summary>
        /// <param name="cred"></param>
        private void manageClient_Sessions(ProjectAuth cred)
        {
            int project_id = 0;

            if (Session["Project_ID"] != null)
            {
                project_id = (int)Session["Project_ID"];
            }

            if (project_id != 0)
            {
                if (project_id != cred.Project_ID)
                {
                    Session["Project_ID"] = cred.Project_ID;
                }
            }
            else if (project_id == 0)
            {
                Session.Add("Project_ID", cred.Project_ID);
            }
        }
コード例 #13
0
        public ActionResult RemoveImage(int id, string confirm_CheckBox)
        {
            if (Session["Project_ID"] == null)
            {
                throw new Exception("What the hell, the client just posted to remove an image without a project id in session.");
            }
            int         project_id = (int)Session["Project_ID"];
            ProjectAuth cred       = check_clientRelation(project_id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectDeleteImageViewModel modifyModel = new Models.ProjectDeleteImageViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, project_id);
            modifyModel.Image_ID = id;
            if (confirm_CheckBox == "on") // on is the equivalent of true from a checkbox element.
            {
                modifyModel.delete_Image();
            }
            return(Redirect(string.Format("/Project/Details/{0}", project_id)));
        }
コード例 #14
0
        public ActionResult RemoveDocument(int id, string confirm_CheckBox)
        {
            // This method will need that the user be logged in as a project owner so we can get the project id from session.
            if (Session["Project_ID"] == null)
            {
                return(Redirect("/User/Index"));
            }
            int         project_id = (int)Session["Project_ID"];
            ProjectAuth cred       = check_clientRelation(project_id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            Models.ProjectDeleteDocumentViewModel modifyModel = new Models.ProjectDeleteDocumentViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, cred.Project_ID);
            modifyModel.Document_ID = id;
            if (confirm_CheckBox == "on")
            {
                modifyModel.delete_document();
            }
            return(Redirect(string.Format("/Project/Details/{0}", cred.Project_ID)));
        }
コード例 #15
0
        public ActionResult Details(int id, string Project_Message)
        {
            ProjectAuth cred = check_clientRelation(id);

            Models.ProjectIndexViewModel detailsModel = new Models.ProjectIndexViewModel(id);
            detailsModel.get_ProjectData(cred.Project_ID);
            if (cred.Investor_ID != 0 || cred.Entrepreneur_ID != 0 || cred.User_ID != 0)
            {
                if (cred.Investor_ID != 0)
                {
                    detailsModel.message_ProjectOwner(cred.Project_ID, cred.Investor_ID, 3, Project_Message);
                }
                else if (cred.Entrepreneur_ID != 0)
                {
                    detailsModel.message_ProjectOwner(cred.Project_ID, cred.Entrepreneur_ID, 4, Project_Message);
                }
                else if (cred.User_ID != 0)
                {
                    detailsModel.message_ProjectOwner(cred.Project_ID, cred.User_ID, 1, Project_Message);
                }
            }
            return(View(detailsModel));
        }
コード例 #16
0
        /// <summary>
        /// Private method that will fill our auth struct with values we need to guide controller actions.
        /// </summary>
        /// <param name="project_id">The id captured from the client's http request which is the project Id requested.</param>
        /// <returns>An authorization object containing Ids.</returns>
        private ProjectAuth check_clientRelation(int project_id)
        {
            ProjectAuth cred = new ProjectAuth();

            cred.Project_ID = project_id;
            // get our Investor_ID from Session if it exists.
            if (Session["Investor_ID"] != null)
            {
                cred.Investor_ID = (int)Session["Investor_ID"];
            }
            // get our Entrepreneur_ID from Session if it exists.
            if (Session["Entrepreneur_ID"] != null)
            {
                cred.Entrepreneur_ID = (int)Session["Entrepreneur_ID"];
            }
            else
            {
                cred.Valid = false;
            }
            Models.ProjectInitializeViewModel authModel = new Models.ProjectInitializeViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, project_id);
            cred.User_ID = authModel.User_Id;
            cred.Valid   = authModel.Valid;
            return(cred);
        }
コード例 #17
0
        public ActionResult Edit(int id, Models.ProjectEditViewModel updateModel)
        {
            ProjectAuth cred = check_clientRelation(id);

            if (!cred.Valid)
            {
                return(Redirect("/User/Index"));
            }
            try
            {
                Models.ProjectEditViewModel projectModel = new Models.ProjectEditViewModel(User.Identity.GetUserId(), cred.Entrepreneur_ID, id);
                projectModel.Name            = updateModel.Name;
                projectModel.Description     = updateModel.Description;
                projectModel.Investment_Goal = updateModel.Investment_Goal;
                projectModel.Profile_Public  = updateModel.Profile_Public;
                projectModel.update_Project();
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message);
                return(View());
            }
            return(Redirect(string.Format("/Project/Index/{0}", id)));
        }