Exemple #1
0
        public ActionResult Create()
        {
            ViewBag.Restaurantes = db.TblRestaurante;
            var model = new RestauranteViewModel();

            return(View(model));
        }
        public async Task <IHttpActionResult> PostPost(Post post)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Posts.Add(post);

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (PostExists(post.Id))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            var restaurantePost = new RestauranteViewModel
            {
                Content = post.Content,
            };

            return(CreatedAtRoute("DefaultApi", new { id = restaurantePost.Id }, restaurantePost));
        }
        public ActionResult Create()
        {
            //ViewBag.Categorias = db.Restaurantes.ToList();
            var model = new RestauranteViewModel();

            return(View(model));
        }
Exemple #4
0
        public async Task <IActionResult> Put([FromRoute] int id, [FromBody] RestauranteViewModel restauranteViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != restauranteViewModel.RestauranteId)
            {
                return(BadRequest());
            }

            var restaurante = new Restaurante(restauranteViewModel.Nome, restauranteViewModel.RestauranteId);

            db.Entry(restaurante).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!RestauranteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Listar()
        {
            RestauranteViewModel viewRestaurante = new RestauranteViewModel()
            {
                listaAmbientes = _unit.AmbienteRepository.Listar()
            };

            return(View(viewRestaurante));
        }
        //  CREAR RESTAURANTE
        //
        //
        public async Task <ActionResult> RegisterRestaurant(RestauranteViewModel res)
        {
            var user = new ApplicationUser {
                UserName = res.Email, Email = res.Email
            };
            var result = await UserManager.CreateAsync(user, res.Pass);

            return(RedirectToAction("Index", "Restaurante"));
        }
Exemple #7
0
        public ActionResult Edit(string Id)
        {
            var Restaurante = new Restaurante();
            var model       = new RestauranteViewModel();

            var TipoRestaurante = new TipoRestaurante().SelectTipoRestaurantes();
            var RangoPrecio     = new RangoPrecio().SelectRangoPrecios();
            var Ciudad          = new Ciudad().SelectCiudades();

            List <SelectListItem> TipoRestaurantes = new List <SelectListItem>();

            foreach (var item in TipoRestaurante)
            {
                TipoRestaurantes.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> RangoPrecios = new List <SelectListItem>();

            foreach (var item in RangoPrecio)
            {
                RangoPrecios.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            List <SelectListItem> Ciudades = new List <SelectListItem>();

            foreach (var item in Ciudad)
            {
                Ciudades.Add(new SelectListItem {
                    Text = item.Nombre, Value = item.Id.ToString()
                });
            }

            ViewBag.TipoRestaurantes = TipoRestaurantes;
            ViewBag.RangoPrecios     = RangoPrecios;
            ViewBag.Ciudades         = Ciudades;

            Restaurante = Restaurante.SelectRestaurante(int.Parse(Id));

            model.Id                = Restaurante.Id;
            model.Nombre            = Restaurante.Nombre;
            model.IdTipoRestaurante = Restaurante.IdTipoRestaurante;
            model.Valoracion        = Restaurante.Valoracion;
            model.IdRangoPrecio     = Restaurante.IdRangoPrecio;
            model.Direccion         = Restaurante.Direccion;
            model.IdCiudad          = Restaurante.IdCiudad;
            model.Telefono          = Restaurante.Telefono;
            model.LatitudGps        = Restaurante.LatitudGps;
            model.LongitudGps       = Restaurante.LongitudGps;

            return(View(model));
        }
        // GET: Restaurante/Details/5
        public ActionResult Details(int id)
        {
            RestauranteViewModel res = null;

            SessionInitialize();
            RestauranteEN resEN = new RestauranteCAD(session).ReadOIDDefault(id);

            res = new AssemblerRestaurante().ConvertENToModelUI(resEN);
            SessionClose();
            return(View(res));
        }
Exemple #9
0
 public IActionResult Create(RestauranteViewModel restauranteViewModel)
 {
     if (ModelState.IsValid)
     {
         var restaurante = _mapper.Map <Restaurante>(restauranteViewModel);
         _restauranteRepository.Add(restaurante);
         _uow.SaveChanges();
         return(RedirectToAction(nameof(Index)));
     }
     return(View(restauranteViewModel));
 }
Exemple #10
0
        public ActionResult <RestauranteViewModel> Get(string nit)
        {
            var restaurante = _restauranteService.BuscarxNit(nit);

            if (restaurante == null)
            {
                return(NotFound());
            }
            var RestauranteViewModel = new RestauranteViewModel(restaurante);

            return(RestauranteViewModel);
        }
        // GET: Restaurante/Create
        public ActionResult Create()
        {
            RestauranteViewModel res = new RestauranteViewModel();

            TipoCocinaCEN        tipoCocinaCEN   = new TipoCocinaCEN();
            IList <TipoCocinaEN> listaTipoCocina = tipoCocinaCEN.ReadAll(0, -1);

            ViewData["listaTipoCocina"] = listaTipoCocina;


            return(View(res));
        }
        public ActionResult Editar(RestauranteViewModel viewRestaurante)
        {
            Ambiente ambiente = new Ambiente()
            {
                Id   = viewRestaurante.ambiente.Id,
                Nome = viewRestaurante.ambiente.Nome
            };

            _unit.AmbienteRepository.Alterar(ambiente);
            _unit.Salvar();
            return(RedirectToAction("Listar"));
        }
Exemple #13
0
        public IHttpActionResult Create(RestauranteViewModel restaurante)
        {
            try
            {
                var restauranteDomain = Mapper.Map <RestauranteViewModel, Domain.Entities.Restaurante>(restaurante);
                _restauranteApp.Add(restauranteDomain);

                return(Content(HttpStatusCode.OK, restauranteDomain));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.InternalServerError, ex.ToString()));
            }
        }
Exemple #14
0
        public void Post([FromBody] RestauranteViewModel model)
        {
            var restaurante = new Restaurante();

            _mapper.Map(model, restaurante);
            //var restaurante = new Restaurante
            //{
            //    Nombre = model.Nombre,
            //    Domicilio = model.Direccion,
            //    PaginaWeb = model.PaginaWeb,
            //    HoraDeCierre = model.HoraDeCierre
            //};
            _restauranteService.Agregar(restaurante);
        }
Exemple #15
0
        public async Task <IActionResult> Post([FromBody] RestauranteViewModel restauranteViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var restaurante = new Restaurante(restauranteViewModel.Nome);

            db.Restaurantes.Add(restaurante);
            await db.SaveChangesAsync();

            return(CreatedAtAction(nameof(Get), new { id = restaurante.RestauranteId }, restaurante));
        }
        public ActionResult Delete(RestauranteViewModel res)
        {
            try
            {
                // TODO: Add delete logic here
                new RestauranteCEN().Destroy(res.Id);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        public IActionResult Post([FromBody] RestauranteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(ResponseModelStateError());
            }

            var restaurante = _mapper.Map <Restaurante>(model);

            _restauranteRepository.Add(restaurante);
            _uow.SaveChanges();

            return(ResponseOk(model));
        }
        public ActionResult Create(RestauranteViewModel res) //RestauranteEN resEN
        {
            try
            {
                RestauranteCEN cen = new RestauranteCEN();
                cen.New_(res.Email, res.Pass, res.Fecha_inscripcion, res.Nombre, res.Fecha_apertura, res.Tipo, res.Max_comen, res.Current_comen, res.Precio_medio, res.Descripcion, res.Menu);

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #19
0
        public IActionResult Editar(RestauranteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Te hacen falta campos");
                return(View(model));
            }

            var restaurante = _restauranteService.Obtener(model.Id);

            restaurante.Nombre = model.Nombre;

            _restauranteService.Editar(restaurante);

            return(RedirectToAction("Index"));
        }
        public async Task <IHttpActionResult> GetPost(Guid id)
        {
            Post post = await db.Posts.FirstOrDefaultAsync(p => p.Id == id && p.PostType == PostTypeEnum.Restaurante);

            if (post == null)
            {
                return(NotFound());
            }

            var RestaurantePost = new RestauranteViewModel
            {
                Content = post.Content,
            };

            return(Ok(RestaurantePost));
        }
        public ActionResult Edit(RestauranteViewModel res) //Restaurante res
        {
            try
            {
                // TODO: Add update logic here

                RestauranteCEN cen = new RestauranteCEN();
                cen.Modify(res.Id, res.Email, res.Pass, res.Fecha_inscripcion, res.Nombre, res.Fecha_apertura, res.Max_comen, res.Current_comen, res.Precio_medio, res.Descripcion, res.Menu); //parametros restaurante

                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
Exemple #22
0
        public IActionResult Editar(int id)
        {
            ViewData["Accion"] = "Editar";
            var restaurante = _restauranteService.Obtener(id);

            var viewModel = new RestauranteViewModel
            {
                Id           = restaurante.Id,
                Nombre       = restaurante.Nombre,
                Direccion    = restaurante.Domicilio,
                HoraDeCierre = restaurante.HoraDeCierre.GetValueOrDefault(),
                PaginaWeb    = restaurante.PaginaWeb,
                Telefono     = restaurante.Telefono.ToString(),
            };

            return(View("Agregar", viewModel));
        }
        public ActionResult Edit([Bind(Include = "RestauranteId,Nome")] RestauranteViewModel restaurante)
        {
            if (ModelState.IsValid)
            {
                Restaurante rest = new Restaurante()
                {
                    Nome          = restaurante.Nome,
                    RestauranteId = restaurante.RestauranteId
                };

                repRestaurante.Alterar(rest);
                repRestaurante.SalvarTodos();

                return(RedirectToAction("Index"));
            }
            return(View(restaurante));
        }
Exemple #24
0
        public ActionResult Put(int id, RestauranteViewModel model)
        {
            var restaurante = _restauranteService.Obtener(id);

            if (restaurante == null)
            {
                return(BadRequest());
            }

            restaurante.Nombre    = model.Nombre;
            restaurante.PaginaWeb = model.PaginaWeb;
            restaurante.Telefono  = int.Parse(model.Telefono);

            _restauranteService.Editar(restaurante);

            return(Ok());
        }
Exemple #25
0
        public ActionResult Create(RestauranteViewModel model)
        {
            if (ModelState.IsValid)
            {
                var restaurante = new Restaurante();
                restaurante.NomeRestaurante = model.NomeRestaurante;
                restaurante.IdRestaurante   = model.IdRestaurante;

                db.TblRestaurante.Add(restaurante);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            // Se ocorrer um erro retorna para pagina
            ViewBag.Restaurantes = db.TblRestaurante;
            return(View(model));
        }
Exemple #26
0
        public IActionResult Edit(Guid id, RestauranteViewModel restauranteViewModel)
        {
            if (id != restauranteViewModel.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                var restaurante = _mapper.Map <Restaurante>(restauranteViewModel);
                _restauranteRepository.Update(restaurante);
                _uow.SaveChanges();
                return(RedirectToAction(nameof(Index)));
            }

            return(View(restauranteViewModel));
        }
Exemple #27
0
        public ActionResult New(RestauranteViewModel model)
        {
            if (!ModelState.IsValid)
            {
                var TipoRestaurante = new TipoRestaurante().SelectTipoRestaurantes();
                var RangoPrecio     = new RangoPrecio().SelectRangoPrecios();
                var Ciudad          = new Ciudad().SelectCiudades();

                List <SelectListItem> TipoRestaurantes = new List <SelectListItem>();
                foreach (var item in TipoRestaurante)
                {
                    TipoRestaurantes.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                List <SelectListItem> RangoPrecios = new List <SelectListItem>();
                foreach (var item in RangoPrecio)
                {
                    RangoPrecios.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                List <SelectListItem> Ciudades = new List <SelectListItem>();
                foreach (var item in Ciudad)
                {
                    Ciudades.Add(new SelectListItem {
                        Text = item.Nombre, Value = item.Id.ToString()
                    });
                }

                ViewBag.TipoRestaurantes = TipoRestaurantes;
                ViewBag.RangoPrecios     = RangoPrecios;
                ViewBag.Ciudades         = Ciudades;

                return(View(model));
            }

            var Restaurante = new Restaurante();

            Restaurante.InsertRestaurante(model.Nombre, model.IdTipoRestaurante, model.IdRangoPrecio, model.Direccion, model.IdCiudad, model.Telefono, model.LatitudGps, model.LongitudGps);

            return(RedirectToAction("Index"));
        }
Exemple #28
0
        public IActionResult Index()
        {
            var restaurante = new RestauranteViewModel {
                Nombre         = "Luigi's Pizza",
                Direccion      = "Ave ejemplo",
                NumeroExterior = 123,
                TipoDeComida   = "Torta",
                FechaDeAlta    = DateTime.Now,
                Ordenes        = new List <int>
                {
                    1,
                    5,
                    6
                }
            };

            return(View(restaurante));
        }
        // GET: Restaurante/Edit/5
        public ActionResult Edit(int id)
        {
            RestauranteViewModel res = null;

            SessionInitialize();

            TipoCocinaCEN        tipoCocinaCEN   = new TipoCocinaCEN();
            IList <TipoCocinaEN> listaTipoCocina = tipoCocinaCEN.ReadAll(0, -1);

            ViewData["listaTipoCocina"] = listaTipoCocina;

            RestauranteEN resEN = new RestauranteCAD(session).ReadOIDDefault(id);

            res = new AssemblerRestaurante().ConvertENToModelUI(resEN);
            SessionClose();

            return(View(res));
        }
Exemple #30
0
        public RestauranteViewModel ConvertENToModelUI(RestauranteEN en)
        {
            RestauranteViewModel res = new RestauranteViewModel();

            res.Id                = en.Id;
            res.Email             = en.Email;
            res.Pass              = en.Pass;
            res.Fecha_inscripcion = (System.DateTime)en.Fecha_inscripcion;
            res.Nombre            = en.Nombre;
            res.Fecha_apertura    = (System.DateTime)en.Fecha_apertura;
            res.Max_comen         = en.Max_comen;
            res.Current_comen     = en.Current_comen;
            res.Precio_medio      = en.Precio_medio;
            res.Descripcion       = en.Descripcion;
            res.Menu              = en.Menu;
            res.Tipo              = en.TipoCocina.Tipo;
            return(res);
        }