Ejemplo n.º 1
0
        private SharkService CreateSharkService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SharkService(userId);

            return(service);
        }
Ejemplo n.º 2
0
        public ActionResult Edit(int id)
        {
            var service = CreateSharkTagService();
            var detail  = service.GetSharkTagById(id);


            var userId   = Guid.Parse(User.Identity.GetUserId());
            var sservice = new SharkService(userId);
            var tservice = new TagService(userId);
            var lservice = new LocationService(userId);

            List <Shark>    sharks    = sservice.GetSharksList().ToList();
            List <Tag>      tags      = tservice.GetTagsList().ToList();
            List <Location> locations = lservice.GetLocationsList().ToList();

            ViewBag.SharkId = sharks.Select(s => new SelectListItem()
            {
                Value    = s.SharkId.ToString(),
                Text     = s.SharkName,
                Selected = detail.SharkId == s.SharkId
            });

            ViewBag.TagId = tags.Select(t => new SelectListItem()
            {
                Value    = t.TagId.ToString(),
                Text     = t.TagId.ToString(),
                Selected = detail.TagId == t.TagId
            });

            ViewBag.LocationId = locations.Select(l => new SelectListItem()
            {
                Value    = l.LocationId.ToString(),
                Text     = l.TaggingLocation,
                Selected = detail.LocationId == l.LocationId
            });



            var model = new SharkTagEdit
            {
                SharkTagId = detail.SharkTagId,
                StartDate  = detail.StartDate,
                EndDate    = detail.EndDate,
                SharkId    = detail.SharkId,
                TagId      = detail.TagId,
                LocationId = detail.LocationId
            };

            return(View(model));
        }
Ejemplo n.º 3
0
        // GET: Shark
        public ActionResult Index(SharkListItem name, string search)
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SharkService(userId);
            var model   = service.GetSharks();

            if (search != null)
            {
                return(View(model.Where(x => x.SharkName.StartsWith(search, StringComparison.OrdinalIgnoreCase) || search == null).ToList()));
            }
            else
            {
                return(View(model));
            }
        }
Ejemplo n.º 4
0
        public ActionResult Create()
        {
            var userId   = Guid.Parse(User.Identity.GetUserId());
            var sservice = new SharkService(userId);
            var tservice = new TagService(userId);
            var lservice = new LocationService(userId);

            List <Shark>    sharks    = sservice.GetSharksList().ToList();
            List <Tag>      Tags      = tservice.GetTagsList().ToList();
            List <Location> locations = lservice.GetLocationsList().ToList();



            var query = from s in sharks
                        select new SelectListItem()
            {
                Value = s.SharkId.ToString(),
                Text  = s.SharkName
            };
            var tquery = from t in Tags
                         select new SelectListItem()
            {
                Value = t.TagId.ToString(),
                Text  = t.TagId.ToString()
            };
            var lquery = from l in locations
                         select new SelectListItem()
            {
                Value = l.LocationId.ToString(),
                Text  = l.TaggingLocation
            };

            ViewBag.SharkId    = query;
            ViewBag.TagId      = tquery;
            ViewBag.LocationId = lquery;
            return(View());
        }