problem with editor file upload!

problem with editor file upload!

eyal_hbeyal_hb Posts: 98Questions: 31Answers: 0

this is my code

public ActionResult GetDataToursForSale(Enums.JsonSortType type, int id)
        {
            var settings = Properties.Settings.Default;
            var formData = HttpContext.ApplicationInstance.Context.Request;

            using (var db = new DataTables.Database(settings.DbType, settings.DbConnection))
            {
                var editor = new Editor(db, "Tour_For_Sale", "TourForSale_Id");
                if (type == PegasusOperation.Common.Classes.Enums.JsonSortType.TourForSaleByTour)
                {
                    editor.Where(q =>
                    q.Where("Tour_For_Sale.TourForSale_Id", "(SELECT TourForSale_Id FROM Tour_For_Sale WHERE Tour_Id= " + id + ")", "IN", false)
                    );
                }
                editor.Model<Model.Tours_For_Sale_EditorVM>("Tour_For_Sale")
                .Field(new Field("Tour_For_Sale.TourForSale_Id")
                    .Validator(Validation.Numeric())
                )
                .Field(new Field("Tour_For_Sale.Tour_For_Sale_Name").Xss(false)
                .Validator(Validation.MaxLen(225))
                .Validator(Validation.Unique<string>(new ValidationOpts { Message = "טיול למכירה בשם כזה קיים בטבלה" }, "Tour_For_Sale_Name", "Tour_For_Sale", db))
                .Validator(Validation.NotEmpty(new ValidationOpts
                {
                    Message = " חובה לתת שם לטיול מכירה"
                }))
                )
                .Field(new Field("Tour_For_Sale.TourForSale_Code").Xss(false)
                )
                .Field(new Field("Tour_For_Sale.Departure_Date_Start").Xss(false)
                .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.Departure_Date_End").Xss(false)
                .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.Tour_Id").Xss(false)
                .Options(new Options()
                        .Table("Tours_Operation")
                        .Value("Tour_Id")
                        .Order("Tours_Operation.Tour_Id")
                        .Label("Tour_Name"))
                 .Validator(Validation.Numeric())
                 .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.AirLineComapny_Id").Xss(false)
                .Options(new Options()
                        .Table("AirlineCompany")
                        .Value("Airline_Company_id")
                        .Order("AirlineCompany.Airline_Company_id")
                        .Label("Airline_Company_Name"))
                 .Validator(Validation.Numeric())
                 .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.Title_Page_Tour").Xss(false)
                .Validator(Validation.MaxLen(250))
                .SetFormatter(Format.IfEmpty(null)))
                .Field(new Field("Tour_For_Sale.Tour_Duration").Xss(false)
                .Validator(Validation.MaxLen(250))
                .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.TourForSale_Category").Xss(false)
                .Options(new Options()
                        .Table("Tours_Categories")
                        .Value("Category_Id")
                        .Order("Tours_Categories.Category_Id")
                        .Label("Category_Name"))
                 .Validator(Validation.Numeric())
                 .SetFormatter(Format.IfEmpty(null))
                )
                 .Field(new Field("Tour_For_Sale.TourForSale_SubCategory").Xss(false)
                 .Options(new Options()
                        .Table("Tours_SubCategories")
                        .Value("SubCategory_Id")
                        .Order("Tours_SubCategories.SubCategory_Id")
                        .Label("SubCategory_Name"))
                 .Validator(Validation.Numeric())
                 .SetFormatter(Format.IfEmpty(null))
                )
                 .Field(new Field("Tour_For_Sale.Html_Title").Xss(false)
                  .Validator(Validation.MaxLen(250))
                  .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.Meta_Description").Xss(false)
                  .Validator(Validation.MaxLen(250))
                  .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.Virtual_Url").Xss(false)
                 .Validator(Validation.MaxLen(250))
                  .SetFormatter(Format.IfEmpty(null))
                )
                 .Field(new Field("Tour_For_Sale.Guide_Name").Xss(false)
                 .Validator(Validation.MaxLen(250))
                  .SetFormatter(Format.IfEmpty(null))
                )
                .Field(new Field("Tour_For_Sale.TourForSale_Department_Id").Xss(false)
                 .Options(()=> Functions.getOptionsDepartments())
                )
                .Field(new Field("Tour_For_Sale.Tour_File")
                .Upload(new Upload((file,fileId) => {
                    file.SaveAs(Request.PhysicalApplicationPath +@"media\TourForSale" + id+""+ System.IO.Path.GetExtension(file.FileName));
                    return @"media\TourForSale" + id+""+ System.IO.Path.GetExtension(file.FileName);
                    })
                
                ))
               .MJoin(new MJoin("RoomType")
               .Link("Tour_For_Sale.TourForSale_Id", "Tour_For_Sale_Rooms.TourForSale_Id")
               .Link("RoomType.RoomType_Id", "Tour_For_Sale_Rooms.Room_Type_Id")
               .Model<Model.RoomType>()
               .Order("RoomType.RoomType_Id")
               .Field(new Field("RoomType_Id")
                    .Options("RoomType", "RoomType_Id", "Name_Heb")
                ));
                editor.Process(formData.Unvalidated.Form);
                DtResponse data = editor.Data();
                return Json(data, JsonRequestBehavior.AllowGet);
            }

and this is the message i get when try to add file: File upload requires that 'Process' be called with an HttpRequest or UnvalidatedRequestValues object

Answers

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Could you try using:

    editor.Process(formData.Unvalidated);
    

    please?

    Thanks,
    Allan

  • eyal_hbeyal_hb Posts: 98Questions: 31Answers: 0

    hey Allan i try but i get error on controller:
    cannot convert from 'system.web.unvalidatedRequestValues' to 'DataTables.dtRequest'

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    [This is it here in the code. What version of .NET are you using please?

    I'm thinking that #if NET45 should perhaps be '#if NETFRAMEWORK...

    Allan

  • eyal_hbeyal_hb Posts: 98Questions: 31Answers: 0

    .net framework 4.6.1

  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin

    Thank you. Could you try this dll for .NET 4.6 please? I've modified the preprocessor directive so that function should not be included in this dll.

    Allan

This discussion has been closed.