コード例 #1
0
        private SharkTagService CreateSharkTagService()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SharkTagService(userId);

            return(service);
        }
コード例 #2
0
        //[Route("Ping/Location")]
        //public ViewResult PingLocationDetail(string location)
        //{
        //    using (var ctx = new ApplicationDbContext())
        //    {
        //        var svc = CreatePingService();
        //        var model = svc.GetPingByPingLocation(location);

        //        var locations = from l in ctx.Ping select l;
        //        if (!string.IsNullOrWhiteSpace(location))
        //        {
        //            locations = locations.Where(l => l.PingLocation.Contains(location));
        //        }
        //        return View("PingLocationDetail");
        //    }

        //}

        public ActionResult Edit(int id)
        {
            var service = CreatePingService();
            var detail  = service.GetPingById(id);

            var userId   = Guid.Parse(User.Identity.GetUserId());
            var sservice = new SharkTagService(userId);

            List <SharkTag> SharkTags = sservice.GetSharkTagsList().ToList();

            ViewBag.SharkTagId = SharkTags.Select(s => new SelectListItem()
            {
                Value    = s.SharkTagId.ToString(),
                Text     = s.TagId.ToString(),
                Selected = detail.SharkTagId == s.SharkTagId
            });

            var model = new PingEdit
            {
                PingId       = detail.PingId,
                PingDate     = detail.PingDate,
                PingLocation = detail.PingLocation,
                SharkTagId   = detail.SharkTagId,
            };

            return(View(model));
        }
コード例 #3
0
        // GET: SharkTag
        public ActionResult Index()
        {
            var userId  = Guid.Parse(User.Identity.GetUserId());
            var service = new SharkTagService(userId);
            var model   = service.GetSharkTags();

            return(View(model));
        }
コード例 #4
0
        //Get
        public ActionResult Create()
        {
            var             userId    = Guid.Parse(User.Identity.GetUserId());
            var             service   = new SharkTagService(userId);
            List <SharkTag> sharkTags = service.GetSharkTagsList().ToList();

            var query = from s in sharkTags
                        select new SelectListItem()
            {
                Value = s.SharkTagId.ToString(),
                Text  = s.TagId.ToString()
            };

            ViewBag.SharkTagId = query;
            return(View());
        }