public ActionResult Create(Supplier Supplier, HttpPostedFileBase ImageFile) { if (ImageFile == null) { ModelState.AddModelError("Image", "Please upload an Image"); } bool isValidFormate = common.ImageValidation(ImageFile); if (isValidFormate == false) { ModelState.AddModelError("Image", "only png,jpg,jpeg format is allowed"); } byte[] ConvertedImage = common.ConvertImage(ImageFile); Supplier.Image = ConvertedImage; if (ModelState.IsValid) { status = _supplierBll.Create(Supplier); if (status == true) { return(RedirectToAction("List", "Suppliers")); } else { ViewBag.Message = "Supplier failed to add"; } } return(View(Supplier)); }