Exemple #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));
        }
Exemple #2
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));
        }