コード例 #1
0
        public async Task <ActionResult> Upload()
        {
            int    idSesion    = int.Parse(Request.Form["idSesion"].ToString());
            String sessionName = this.repoSesion.GetSESIONID(idSesion).NAME;

            foreach (string file in Request.Files)
            {
                HttpPostedFileBase fileContent = Request.Files[file];
                String             rootpath    = Server.MapPath("~/images");
                String             path        = Path.Combine(rootpath + "\\Sesion\\" + sessionName);
                ToolImage.UploadImage(fileContent, path, null);
                this.repoPhoto.InsertPhoto(fileContent.FileName, idSesion);
            }

            return(Json(true));
        }
コード例 #2
0
        public async Task <IActionResult> Upload()
        {
            int    idSesion    = int.Parse(Request.Form["idSesion"].ToString());
            String sessionName = this.repoSesion.GetSESIONID(idSesion).Name;

            String path = prov.MapPath(Folders.Session, sessionName);

            foreach (IFormFile file in Request.Form.Files)
            {
                await ToolImage.UploadImage(file, path, null);

                this.repoPhoto.InsertPhoto(file.FileName, idSesion);
            }

            return(Json(true));
        }
コード例 #3
0
        public IActionResult Comision(String name, String description, IFormFile photo, float price, int?id, String option)
        {
            String path = prov.MapPath(Folders.Comision);

            if (option == "ADD")
            {
                if (photo != null && photo.Length > 0)
                {
                    ToolImage.UploadImage(photo, path, name);
                    repo.InsertComision(name, description, "~/images/comision\\", photo, price);
                }
            }
            else if (option == "UPDATE")
            {
                COMISION comision = this.repo.GetComisionByID(id.Value);
                if (comision != null)
                {
                    String image = null;
                    if (photo != null)
                    {
                        String photoRemove = comision.Photo.Split('\\')[1];
                        ToolImage.RemoveImage(photoRemove, path);
                        ToolImage.UploadImage(photo, path, name);

                        String type = photo.ContentType.Split('/')[1];
                        image = name + "." + type;
                    }

                    repo.ModifyComision(id.Value, name, description, "~/images/comision\\", image, price);
                }
            }
            else if (option == "DELETE")
            {
                COMISION comision = this.repo.GetComisionByID(id.Value);
                if (comision != null)
                {
                    repo.DeleteComision(id.Value, path);
                }
            }

            return(RedirectToAction("Comision"));
        }
コード例 #4
0
        public ActionResult Comision(String name, String description, HttpPostedFileBase photo, float price, int?id, String option)
        {
            String ruta = Server.MapPath("~/images/Comision");

            if (option == "ADD")
            {
                if (photo != null && photo.ContentLength > 0)
                {
                    ToolImage.UploadImage(photo, ruta, name);
                    repo.InsertComision(name, description, "~/images/Comision", photo, price);
                }
            }
            else if (option == "UPDATE")
            {
                COMISION comision = this.repo.GetComisionByID(id.Value);
                if (comision != null)
                {
                    String image = null;
                    if (photo != null)
                    {
                        String photoRemove = comision.PHOTO.Split('\\')[1];
                        ToolImage.RemoveImage(photoRemove, ruta);
                        ToolImage.UploadImage(photo, ruta, name);

                        String type = photo.ContentType.Split('/')[1];
                        image = name + "." + type;
                    }

                    repo.ModifyComision(id.Value, name, description, "~/images/Comision\\", image, price);
                }
            }
            else if (option == "DELETE")
            {
                COMISION comision = this.repo.GetComisionByID(id.Value);
                if (comision != null)
                {
                    repo.DeleteComision(id.Value, ruta);
                }
            }

            return(RedirectToAction("Comision"));
        }