public ActionResult Create(ParticipantType participant)
        {
            bool result = ParticipantTypeHelper.SaveParticipantType(participant);

            if (result)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                TempData["msg"] = "<script>alert('Failed to insert data');</script>";
                return(View());
            }
        }
        public ActionResult Edit(string id)
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            var listOfType = ParticipantTypeHelper.GetAllListParticipantType();

            ViewBag.ParticipantType = listOfType.Select(x => new SelectListItem {
                Text = x.Name, Value = x.ID.ToString()
            }).ToList();
            var item = ParticipantHelper.GetDetailParticipant(id);

            if (item.Gender.Equals("Laki-Laki"))
            {
                var listOfGender = new List <SelectListItem>
                {
                    new SelectListItem {
                        Text = "Laki-Laki", Value = "Laki-Laki", Selected = true
                    },
                    new SelectListItem {
                        Text = "Perempuan", Value = "Perempuan"
                    }
                };
                ViewBag.Gender = listOfGender;
            }
            else
            {
                var listOfGender = new List <SelectListItem>
                {
                    new SelectListItem {
                        Text = "Laki-Laki", Value = "Laki-Laki"
                    },
                    new SelectListItem {
                        Text = "Perempuan", Value = "Perempuan", Selected = true
                    }
                };
                ViewBag.Gender = listOfGender;
            }


            return(View(item));
        }
        public ActionResult Create()
        {
            if (Session["Username"] == null)
            {
                return(RedirectToAction("Index", "Login"));
            }
            var listOfType = ParticipantTypeHelper.GetAllListParticipantType();

            ViewBag.ParticipantType = listOfType.Select(x => new SelectListItem {
                Text = x.Name, Value = x.ID.ToString()
            }).ToList();

            var listOfGender = new ObservableCollection <String>();

            listOfGender.Add("Laki-Laki");
            listOfGender.Add("Perempuan");
            ViewBag.Gender = listOfGender.Select(x => new SelectListItem {
                Text = x, Value = x
            }).ToList();

            return(View());
        }
Exemple #4
0
        public IHttpActionResult GetAllParticipantType()
        {
            ParticipantTypeHelper helper = new ParticipantTypeHelper();

            return(Ok(helper.GetAllListParticipantTypeMobile().ToList()));
        }
        // GET: ParticipantType
        public ActionResult Index()
        {
            List <ParticipantType> listOfParticipant = ParticipantTypeHelper.GetAllListParticipantType();

            return(View(listOfParticipant));
        }