public async Task <ActionResult> Create(ManageBannersModel Banner) { var ImageDetail = Request.Params["ImgDetail"]; Banner = JsonConvert.DeserializeObject <ManageBannersModel>(ImageDetail); int i = 0; string directory = "~/TempFiles/Banners/" + Banner.Name; string path = Server.MapPath(directory); foreach (var ban in Banner.ImgDetails) { ban.BannerFile = Request.Files["SlideImg" + i]; if (ban.BannerFile != null) { if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } if (ban.BannerFile != null) { ban.BannerFileName = "SlideImg" + i + Path.GetExtension(Path.Combine(directory, ban.BannerFile.FileName)); } if (System.IO.File.Exists(path + "/" + ban.BannerFileName)) { System.IO.File.Delete(path + "/" + ban.BannerFileName); } ban.BannerFile.SaveAs(path + "/" + ban.BannerFileName); ban.BannerFile = null; } i++; } Banner.UserId = CurrentUser.UserId; Banner.CompanyId = CurrentUser.CompanyId; ResponseModel response = new ResponseModel(); if (Banner.BannerId == null) { Banner.EventAction = 'I'; response = await _Banner.AddUpdateBanner(Banner); } else { Banner.EventAction = 'U'; response = await _Banner.AddUpdateBanner(Banner); } return(Json("Ok", JsonRequestBehavior.AllowGet)); }