Ejemplo n.º 1
0
 public ActionResult Create(CreatePlaceViewModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             placeModel.Create(model);
             return RedirectToAction("Index");
         }
         return View(placeModel.GetCountriesForCreate());
     }
     catch
     {
         return View(placeModel.GetCountriesForCreate());
     }
 }
Ejemplo n.º 2
0
        public void Create(CreatePlaceViewModel model)
        {
            var userModel = new UserModel();
            using (var db = new DBEntitiesProxy())
            {
                var userid = userModel.GetUserID(model.UserEmail);
                db.Place.Add(new Place()
                {
                    Name = model.Name,
                    Content = model.Content,
                    Photo_URI = model.Photo_URI,
                    CountryId = model.CountryId,
                    IsAccepted = false,
                    UserId = userid,
                    AddDate = System.DateTime.Now,
                    Ranking = 1,
                    ContentPL = model.ContentPL,
                    ContentPT = model.ContentPT,

                });
                db.SaveChanges();
            }
        }
Ejemplo n.º 3
0
        public CreatePlaceViewModel GetCountriesForCreate()
        {
            CreatePlaceViewModel model = new CreatePlaceViewModel();
            model.Countries = new List<CountryModel>();
            using (var db = new DBEntitiesProxy())
            {
                model.Countries = db.Country.Select(x => new CountryModel { Code = x.Code, CountryId = x.CountryId, Name = x.Name }).ToList();
            }

            return model;
        }
Ejemplo n.º 4
0
        public CreatePlacePage()
        {
            InitializeComponent();

            BindingContext = new CreatePlaceViewModel();
        }