public ActionResult ParticipantCreate(ParticipantCreateForView model, HttpPostedFileBase Img) { var participant = Mapper.Map <Participant>(model); if (ModelState.IsValid) { string fileName = Path.GetFileName(Img.FileName); string extention = Path.GetExtension(Img.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extention; participant.Img = "~/Image/Participant/" + fileName; string filePath = Path.Combine(Server.MapPath("~/Image/Participant/"), fileName); Img.SaveAs(filePath); var mess = ""; //var contactNo = ""; //var email = ""; var isSave = false; var participantall = _participantBll.GetAll(); for (int i = 0; i < participantall.Count; i++) { if ((model.ContactNo == participantall[i].ContactNo) || (model.Email == participantall[i].Email)) { isSave = true; } } if (isSave == true) { ViewBag.EMsg = "Duplicate"; } else { var isAdded = _participantBll.Add(participant); if (isAdded) { ViewBag.SMsg = "Save Is Successfully"; } else { ViewBag.EMsg = "Save Is UnSuccessfully"; } } model = new ParticipantCreateForView(); model.CourSelectListItems = GetDefaultSelectListItem(); model.OrganiSelectListItems = _organizationBll.GetAll() .Select(c => new SelectListItem() { Value = c.Id.ToString(), Text = c.Name }); model.BathcSelectListItems = GetDefaultSelectListItem(); ViewBag.SmsIs = mess; } return(View(model)); }