// GET: Admin/Musteri/Create public ActionResult Create() { using (BayiRepository bayiRepo = new BayiRepository()) { var bayiler = bayiRepo.Listele(x => !x.Silindi); ViewBag.Bayiler = new SelectList(bayiler, "Id", "Adi");; } return(View()); }
// GET: Admin/Musteri/Edit/5 public ActionResult Edit(int id) { using (BayiRepository bayiRepo = new BayiRepository()) { var bayiler = bayiRepo.Listele(x => !x.Silindi); ViewBag.Bayiler = new SelectList(bayiler, "Id", "Adi");; } using (var repo = new MusteriRepository()) { var model = repo.Getir(x => x.Id == id); return(View(model)); } }
public ActionResult Edit(int id, Musteri model) { try { using (var repo = new MusteriRepository()) { model.GuncellemeTarihi = DateTime.Now; repo.Guncelle(model); } return(RedirectToAction("Index")); } catch (Exception ex) { using (BayiRepository bayiRepo = new BayiRepository()) { var bayiler = bayiRepo.Listele(x => !x.Silindi); ViewBag.Bayiler = new SelectList(bayiler, "Id", "Adi");; } return(View(model)); } }
public ActionResult Create(Musteri model) { try { using (MusteriRepository repo = new MusteriRepository()) { model.KayitTarihi = DateTime.Now; repo.Ekle(model); } return(RedirectToAction("Index")); } catch { //return RedirectToAction(nameof(Create)); using (BayiRepository bayiRepo = new BayiRepository()) { var bayiler = bayiRepo.Listele(x => !x.Silindi); ViewBag.Bayiler = new SelectList(bayiler, "Id", "Adi");; } return(View(model)); } }
public SaveResponse TxtYukle(IUnitOfWork uow, SaveRequest<MyRow> request) { if (request.Entity == null) throw new Exception("Entity null olamaz! "); if (request.Entity.KurumId == null) throw new Exception("KurumId null olamaz! "); if (request.Entity.OptikFormId == null) throw new Exception("OptikFormId null olamaz! "); if (request.Entity.SinavId == null) throw new Exception("SinavId null olamaz! "); if (request.Entity.Txt.IsEmptyOrNull()) throw new Exception("Dosya null olamaz! "); var kurum = new KurumRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = request.Entity.KurumId }).Entity; var optikFormBayi = new OptikFormRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = request.Entity.OptikFormId }).Entity; var sinav = new SinavRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = request.Entity.SinavId }).Entity; var optikFormSinav = new OptikFormRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = request.Entity.OptikFormId }).Entity; var bayi = new BayiRepository().Retrieve(uow.Connection, new RetrieveRequest() { EntityId = 2 }).Entity; if (kurum == null) throw new Exception("Entity null olamaz! "); ////zaten retrieve çağrısında kayıt gelmez ise kendisi otomatik olarak hata dönüyor. if (optikFormSinav == null || optikFormBayi == null) throw new Exception("optikForm null olamaz! "); if (sinav == null) throw new Exception("sinav null olamaz! "); if (bayi == null) throw new Exception("Bayi null olamaz! "); bool optikFormDegistiMi = optikFormBayi.Id != optikFormSinav.Id; //var dd = KurumRow.Fields.IlceAd.PropertyName; //var flds = OptikFormAlanRow.Fields; //var optikFormAlanlari = new OptikFormAlanRepository() // .List(uow.Connection, new ListRequest() { Criteria = new Criteria(OptikFormAlanRow.Fields.FormKodu.PropertyName.ToString()) == optikFormBayi.FormKodu.Value, Sort = new List<SortBy> { new SortBy { Field = OptikFormAlanRow.Fields.Baslangic.PropertyName, Descending = false } }.ToArray() }) // .Entities; //var fldOptikFormAlan = OptikFormAlanRow.Fields; //var qq = new SqlQuery().From(OptikFormAlanRow.Fields.TableName) // .Select(fldOptikFormAlan.AlanAdi) // .Select(fldOptikFormAlan.Baslangic.PropertyName + " as old" + fldOptikFormAlan.Baslangic.PropertyName) // .Select(fldOptikFormAlan.Uzunluk.PropertyName + " as old" + fldOptikFormAlan.Uzunluk.PropertyName) // .Select(fldOptikFormAlan.Baslangic.PropertyName + " as new" + fldOptikFormAlan.Baslangic.PropertyName) // .Select(fldOptikFormAlan.Uzunluk.PropertyName + " as new" + fldOptikFormAlan.Uzunluk.PropertyName) // .Join(new LeftJoin(fldOptikFormAlan.TableName, "T1", new Criteria(fldOptikFormAlan.FormKodu) == 100 & new Criteria(fldOptikFormAlan.FormKodu) == 2001)) // ; //var dd = qq.ToString(); /* new Criteria(fldOptikFormAlan.FormKodu) == 2001 sonuç olarak T0.FormKodu = 2001 sonucu çıkıyor * * coalesce kullanımı == Select(Sql.Coalesce(new string[2] { s.AlanAdi.Expression, b.AlanAdi.Expression })) */ var s = OptikFormAlanRow.Fields.As("s"); var b = OptikFormAlanRow.Fields.As("b"); var sss = new SqlQuery() .From(s) .InnerJoin(b, new Criteria(s.FormKodu) == optikFormSinav.FormKodu.Value & new Criteria(b.FormKodu) == optikFormSinav.FormKodu.Value & new Criteria(s.AlanAdi) == new Criteria(b.AlanAdi)) .Select(s.AlanAdi) .Select(s.Baslangic, "BaslangicS") .Select(s.Uzunluk, "UzunlukS") .Select(b.Baslangic, "BaslangicB") .Select(b.Uzunluk, "UzunlukB") .OrderBy(s.Baslangic); List<OptikFormEslestirmeView> optikFormAlanlari = new List<OptikFormEslestirmeView>(); using (IDataReader reader = SqlHelper.ExecuteReader(uow.Connection, sss)) { while (reader.Read()) { OptikFormEslestirmeView tRow = new OptikFormEslestirmeView(); tRow.AlanAdi = reader.AsString(0); tRow.SinavBaslangic = reader.AsInt32(1); tRow.SinavUzunluk = reader.AsInt32(2); tRow.BayiBaslangic = reader.AsInt32(3); tRow.BayiUzunluk= reader.AsInt32(4); optikFormAlanlari.Add(tRow); } } // .Where(filter) // .GetFirst(connection)) //{ // return row; //} int offset = 395; int length = 20; var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\upload\" + request.Entity.Txt.Replace("/", "\\")); var pp = Server.MapPath("~/App_Data/upload/" + request.Entity.Txt); StringBuilder sb = new StringBuilder(); using (StreamReader sr = new StreamReader(pp)) { while (!sr.EndOfStream) { string lineOld = sr.ReadLine(); string lineNew = ""; int lastIndex = 0; lineNew = lineNew.PadLeft(lineOld.Length); //sb.Insert(0, lineNew); //sb.Insert(0, Regex.Replace(lineOld, @"[\s\S]*", " ")); if (!lineOld.IsEmptyOrNull()) { string myData; foreach (var optikFormAlan in optikFormAlanlari) { myData = lineOld.Substring(optikFormAlan.BayiBaslangic.Value-1, optikFormAlan.BayiUzunluk.Value); lineNew= lineNew.Insert(optikFormAlan.SinavBaslangic.Value - 1, myData); lineNew = lineNew.Substring(0, lineNew.Length - myData.Length); //lastIndex = optikFormAlan.SinavBaslangic.Value + optikFormAlan.SinavUzunluk.Value-1; } sb.Append(lineNew); sb.AppendLine(); } } } System.IO.File.WriteAllText(@"C:\MyNewTextFile" + DateTime.Now.ToString("YYYYddMMss") + ".txt", sb.ToString()); // var optikFormAlanlari = new OptikFormAlanRepository().List(uow.Connection, new ListRequest() { Criteria = new Criteria("FormKodu")== 87 }).Entities; throw new Exception("dsa"); //var o = OptikFormAlanRow.Fields.As("o"); //var n = OptikFormAlanRow.Fields.As("n"); //var query = new SqlQuery() // .From(o) // .LeftJoin(n, o.AlanAdi == n.AlanAdi) // .Select(o.AlanAdi, "AlanAdi") // .Select(o.Baslangic, "oldBaslangic") // .Select(o.Uzunluk, "oldUzunluk") // .Select(n.Baslangic, "newBaslangic") // .Select(n.Uzunluk, "newUzunluk"); //var ddd = query.ToString(); return new MyRepository().TxtYukle(uow, request); }