public ActionResult Add(AddFileViewModel model) { if (!ModelState.IsValid) { return(View(model)); } if (model.file != null) { if (model.file.ContentType != "application/vnd.ms-excel") { TempData["Erors"] = "Неправильное расширение файла, загрузите файл с расширением xls"; return(View()); } else { try { var fileName = this.HttpContext.Request.MapPath("~/Content/shedule.xls"); model.file.SaveAs(fileName); IEnumerable <busStop> answer = SheduleCreator.Create(fileName); repository.DeleteAll(); repository.AddStops(answer); TempData["Success"] = "Расписание добавлено"; } catch { TempData["Erors"] = "Ошибка при обработке файла, проверьте правильность файла"; } return(View()); } } else { TempData["Erors"] = "Выберите файл"; return(View()); } }