public ActionResult Createbadge(badgeDTO dto, FormCollection frm) { if (ModelState.IsValid) { HttpPostedFileBase badgfile = Request.Files["upbadge"]; string Badge_logo = UploadImg(badgfile); if (!string.IsNullOrEmpty(Badge_logo)) { _ichp = (ChallengePres)_ichp; int cnt = _ichp.Badge_count(dto.Badgename); if (cnt == 0) { badgeDTO adto = new badgeDTO(); adto.Badgename = dto.Badgename; adto.badgeImage = Badge_logo; adto.cdescription = dto.cdescription; adto.ldescription = dto.ldescription; string msg = _ichp.Save_badge(adto); if (msg == "success") { TempData["Success"] = "Saved Successfully"; return(RedirectToAction("badges")); } } else { ModelState.AddModelError("", "Badge name already exist..!"); } } } return(View()); }
public ActionResult CreateChallenge(ChallengeDTO dto, FormCollection frm) { // if (ModelState.IsValid) // { HttpPostedFileBase dogfile = Request.Files["updog"]; string dog_img = UploadImg(dogfile); HttpPostedFileBase catfile = Request.Files["upcat"]; string cat_img = UploadImg(catfile); List <ChallengeDTO> chdto = new List <ChallengeDTO>(); chdto = _ichp.GetBadges(); ViewData["bagdelist"] = chdto; if (!string.IsNullOrEmpty(dog_img) && !string.IsNullOrEmpty(cat_img)) { _ichp = (ChallengePres)_ichp; int cnt = _ichp.chalange_count(dto.ChallengeName); if (cnt == 0) { ChallengeDTO adto = new ChallengeDTO(); adto.ChallengeName = dto.ChallengeName; adto.Description = dto.Description; adto.CatDescription = dto.CatDescription; adto.BID = dto.BID; adto.dogchImg = dog_img; adto.catchImg = cat_img; adto.ChcreatedDate = dto.ChcreatedDate; string msg = _ichp.Save_challenge(adto); if (msg == "success") { TempData["Success"] = "Saved Successfully"; return(RedirectToAction("Challenges")); } } } // } return(View()); }