コード例 #1
0
        public void DeleteComision(int id, String folder)
        {
            COMISION comision = GetComisionByID(id);
            String   file     = comision.Photo.Split('\\')[1];

            File.Delete(folder + "\\" + file);
            this.context.DeleteComision(id);
        }
コード例 #2
0
        public void DeleteComision(int id, String folder)
        {
            COMISION comision = GetComisionByID(id);
            String   file     = comision.PHOTO.Split('\\')[1];

            File.Delete(folder + "\\" + file);
            this.entity.DELETECOMISION(id);
        }
コード例 #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"));
        }