Exemplo n.º 1
0
        protected void GridTouristUnitView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
        {
            var listSaP = (List <TouristUnitViewModel>)GridTouristUnitView.DataSource;
            TouristUnitViewModel model = listSaP.Find(m => m.id == e.Keys[0].ToString());

            model.Bathrooms = e.NewValues["Bathrooms"] == null ? 0 : (int)e.NewValues["Bathrooms"];
            model.Bedroom   = e.NewValues["Bedroom"] == null ? 0 : (int)e.NewValues["Bedroom"];
            //  model.SiteCode = e.NewValues["SiteCode"].ToString() ?? string.Empty;
            //model.SiteName = e.NewValues["SiteName"].ToString() ?? string.Empty;
            //model.Beds = e.NewValues["Beds"] == null ? 0 : (int)e.NewValues["Beds"];
            //model.ImageGalleryPath = e.NewValues["ImageGalleryPath"].ToString() ?? string.Empty;
            //model.ImageThumbnailsPath = e.NewValues["ImageThumbnailsPath"].ToString() ?? string.Empty;
            model.CloseDate = e.NewValues["CloseDate"] == null ? DateTime.Now : (DateTime)e.NewValues["CloseDate"];
            //model.CountryName = e.NewValues["CountryName"].ToString() ?? string.Empty;
            model.MaxAdults     = e.NewValues["MaxAdults"] == null ? 0 : (int)e.NewValues["MaxAdults"];
            model.Description   = e.NewValues["Description"] == null ? string.Empty : e.NewValues["Description"].ToString();
            model.MaxPersons    = e.NewValues["MaxPersons"] == null ? 0 : (int)e.NewValues["MaxPersons"];
            model.MobilhomeArea = e.NewValues["MobilhomeArea"] == null ? 0 : (int)e.NewValues["MobilhomeArea"];
            model.OpenDate      = e.NewValues["OpenDate"] == null ? DateTime.Now : (DateTime)e.NewValues["OpenDate"];
            //model.PlaceName = e.NewValues["PlaceName"].ToString() ?? string.Empty;


            //model.RegionName = e.NewValues["RegionName"].ToString() ?? string.Empty;
            model.TerraceArea           = e.NewValues["TerraceArea"] == null ? 0 : (int)e.NewValues["TerraceArea"];
            model.TourOperatorCode      = e.NewValues["TourOperatorCode"].ToString() ?? string.Empty;
            model.TravelServiceProvider = (string)e.NewValues["TravelServiceProvider"] ?? string.Empty;
            model.UnitCode = e.NewValues["UnitCode"].ToString() ?? string.Empty;
            //model.UnitOfferInfoList = (List<UnitOfferInfo>)e.NewValues["SiteName"];
            model.UnitTitel = e.NewValues["UnitTitel"].ToString() ?? string.Empty;

            TouristUnitViewModel touristunit = new TouristUnitViewModel();

            if (model.SiteCode != null)
            {
                //TODO: Ove podatke ne treba ovdje puniti nego u Repositoriju
                // prebaciti model u Repository i dodati property koje fale
                //Ili pozvati jednu funkciju koja vraca jedan objekt sa svim GEO informacijama
                touristunit = controller.GetTouristUnit(model);
            }

            //bool contains = controller.ContainsUnitCode(model.UnitCode);

            //if (!contains)
            //{
            controller.UpdateTouristUnit(touristunit);
            //}

            e.Cancel = true;
            GridTouristUnitView.CancelEdit();

            Bind();
        }
Exemplo n.º 2
0
        protected void GridTouristUnitView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
        {
            //TODO: Zasto ovdje pravis model i punis sa podacima kada kada ti je potreban samo id ????


            string id = e.Keys[0].ToString();


            controller.DeleteTouristUnit(id);
            e.Cancel = true;
            GridTouristUnitView.CancelEdit();

            Bind();
        }