Пример #1
0
        public IActionResult CreateSesion(String name, String description, DateTime date, int comision)
        {
            String path = prov.MapPath(Folders.Session, name);

            ToolImage.CreateFolder(path);
            this.repoSesion.InsertSesion(name, description, date, comision);
            return(RedirectToAction("Sesion"));
        }
Пример #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));
        }
        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"));
        }