Example #1
0
        // GET: api/BeachApi/5
        public IHttpActionResult GetBeach(string id)
        {
            var beachAccess = _db.BeachAccesses.FirstOrDefault(e => e.AccessCode == id);

            if (beachAccess == null)
            {
                return(NotFound());
            }
            var beach = _db.Beaches.Find(beachAccess.Beach.Id);

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

            var beachVm = new BeachViewModel()
            {
                BeachId      = beach.Id,
                Name         = beach.Name,
                CustomerLogo = beach.Customer.Logo,
                CustomerName = beach.Customer.Name,
                StartPoint   = beach.StartPoint,
                EndPoint     = beach.EndPoint,
                LastSeaPoint = beach.LastSeaPoint
            };


            return(Ok(beachVm));
        }
        public ActionResult Create(BeachViewModel model)
        {
            if (ModelState.IsValid)
            {
                var beach = new Beach();
                beach.InjectFrom <UnflatLoopValueInjection>(model);
                _service.CreateBeach(beach);
                return(RedirectToAction("Manager"));
            }

            return(View(model));
        }