public ActionResult Index(AfetDetayAdresViewModel model, HttpPostedFileBase dosyaYolu) { List <Il> iller = new List <Il>(); foreach (Il item in _ilBLL.GetAll()) { iller.Add(item); } ViewBag.Il = new SelectList(iller, "IlId", "IlAdi"); TumAfetTurleriGetir(); OnayDurumlariGetir(); string basePath = Server.MapPath("~\\App_Data\\uploads"); if (!Directory.Exists(basePath)) { Directory.CreateDirectory(basePath); } if (dosyaYolu.ContentLength > 0) { var dosyaAdi = Path.GetFileName(dosyaYolu.FileName); var path = Path.Combine(Server.MapPath("~/App_Data/uploads"), dosyaAdi); model.Afet.DosyaYolu = path; dosyaYolu.SaveAs(path); } string sure = _afetBLL.TarihlerArasindakiFark(model.Afet.BaslangicTarihi, model.Afet.BitisTarihi).ToString(); model.Afet.Sure = sure; ViewBag.Sure = sure; model.Afet.AfetTuruId = model.AfetTuru.AfetTuruId; Adres adres = new Adres(); adres.BeldeId = model.Belde.BeldeId; adres.IlId = model.Il.IlId; adres.IlceId = model.Ilce.IlceId; adres.MahalleId = model.Mahalle.MahalleId; try { _afetBLL.Add(model.Afet); _adresBLL.Add(adres); return(RedirectToAction("KayitOlusturuldu")); } catch (Exception ex) { ViewBag.Hata = ex.Message; } return(View()); }
public ActionResult Index() { List <Il> iller = new List <Il>(); foreach (Il item in _ilBLL.GetAll()) { iller.Add(item); } ViewBag.Il = new SelectList(iller, "IlId", "IlAdi"); TumAfetTurleriGetir(); OnayDurumlariGetir(); AfetDetayAdresViewModel model = new AfetDetayAdresViewModel(); return(View(model)); }