public ActionResult Create(CreatedRecipePostModel createdRecipePostVM) { if (ModelState.IsValid) { if (createdRecipePostVM.ImageFile != null) { string fileName = Path.GetFileNameWithoutExtension(createdRecipePostVM.ImageFile.FileName); string extension = Path.GetExtension(createdRecipePostVM.ImageFile.FileName); fileName = fileName + DateTime.Now.ToString("yymmssfff") + extension; var path = Path.Combine(Server.MapPath("~/Images/"), fileName); createdRecipePostVM.ImageFile.SaveAs(path); createdRecipePostVM.ImagePath = "~/Images/" + fileName; } var createdRecipeModel = _mapper.Map <CreatedRecipeModel>(createdRecipePostVM); _recipeManager.Create(createdRecipeModel); return(RedirectToAction("Index")); } return(View(createdRecipePostVM)); }