Example #1
0
        public ActionResult Create(Contestant_VM vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.PhotoFile != null)
                {
                    vm.PhotoUrl = UploadFile(vm.PhotoFile);
                }


                var obj = vm.VM_To_Domain();
                _Service.InsertContestant(obj);

                var cid = obj.Id;
                //Insert ratting of contestant
                _ContestantRatingService.InsertContestantRating(new ContestantRating {
                    ContestantId = cid, RatedDate = DateTime.Now, Rating = 0
                });


                TempData["Message"] = new string[] { "success", "Contestant", "Added Succesfully." };
                return(RedirectToAction("Index"));
            }

            LoadDDL();
            TempData["Message"] = new string[] { "error", "Contestant", "Validation Error" };
            ViewBag.ActionName  = "Create";
            return(View(vm));
        }
Example #2
0
        // GET: Contestant/Create
        public ActionResult Create()
        {
            LoadDDL();
            var obj = new Contestant_VM();

            ViewBag.ActionName = "Create";

            return(View(obj));
        }
Example #3
0
        public ActionResult Edit(Contestant_VM vm)
        {
            if (ModelState.IsValid)
            {
                if (vm.PhotoFile != null)
                {
                    vm.PhotoUrl = UploadFile(vm.PhotoFile);
                }

                var obj = vm.VM_To_Domain();

                _Service.UpdateContestant(obj);

                TempData["Message"] = new string[] { "success", "Contestant", "Update Succesfully." };
                return(RedirectToAction("Index"));
            }

            LoadDDL();
            TempData["Message"] = new string[] { "error", "Contestant", "Validation Error" };
            ViewBag.ActionName  = "Edit";
            return(View("Create", vm));
        }