/// <summary> /// Gönderilen depo entity'sini veritabanına ekler. /// Hata alması durumunda -1 döner. /// </summary> /// <param name="depo"></param> /// <returns></returns> public int DepoEkle(DepoDto depo) { int result = -1; DynamicTryCatch.TryCatchLogla(() => { result = _uow.GenericRepository <DepoDto>().InsertWithProcedure("Exec Insert_Depo @DepoKodu, @DepoAdi, @AktifMi", new SqlParameter("@DepoKodu", SqlDbType.VarChar) { Value = depo.DepoKodu }, new SqlParameter("@DepoAdi", SqlDbType.VarChar) { Value = depo.DepoAdi }, new SqlParameter("@AktifMi", SqlDbType.Bit) { Value = depo.AktifMi }); _uow.Dispose(); } , MethodBase.GetCurrentMethod().Name); return(result); }
public async Task <IEnumerable <DepoDto> > GetByOrganizationAsync(int?organId) { var organs = organId is null ? await _unitOfWork.Depos.GetAsync() : await _unitOfWork.Depos.GetAsync(d => d.OrganizationId == organId); return(organs.Select(d => DepoDto.FromDomain(d)).ToList()); }
public async Task <PageDto <DepoDto> > GetPageAsync(int pageSize, int pageNumber) { var page = new PageDto <DepoDto>(pageSize, pageNumber); var items = await _unitOfWork.Depos.GetPageAsync(pageSize, pageNumber); page.SetData(items.Item2, items.Item1.Select(i => DepoDto.FromDomain(i)).ToList()); return(page); }
private void DepoSil() { dtoDepo = new DepoDto(); dtoDepo = (DepoDto)gridView1.GetRow(gridView1.FocusedRowHandle); CudEnums enums = bllDepo.DepoSil(dtoDepo); FormHelpers.ShowMessage(enums); DepolariGetir(); }
public async Task <DepoDto> GetAsync(int id) { var depoDto = await _cacheStore.StoreAndGetAsync(GetCacheKey(id), async() => { var depo = await Get(id); return(DepoDto.FromDomain(depo)); }); return(depoDto); }
public async Task <DepoDto> UpdateAsync(DepoDto dto) { await _unitOfWork.Depos.GuardForDuplicateDepoName(dto.Name, dto.Id); var depo = await Get(dto.Id); await Task.WhenAll(_unitOfWork.CompleteAsync(ctx => depo.Update(dto.Name, dto.OrganizationId, dto.StationId)), _cacheStore.RemoveAsync(GetCacheKey(dto.Id))); return(dto); }
/// <summary> /// DepoDto tipinde entity alır ve veritabanında deaktif eder. /// Hata alması durumunda -1 döner. /// </summary> /// <param name="depo"></param> /// <returns></returns> public int DepoSil(DepoDto depo) { int result = -1; DynamicTryCatch.TryCatchLogla(() => { _uow.GenericRepository <DepoDto>().Update(depo); result = _uow.Commit(); _uow.Dispose(); }, "StokTakibi.DAL.Operations.Depo.DepoDuzenle"); return(result); }
/// <summary> /// DepoDto tipinde entity alır ve veritabanında günceller. /// Hata alması durumunda -1 döner. /// </summary> /// <param name="depo"></param> /// <returns></returns> public int DepoDuzenle(DepoDto depo) { int result = -1; DynamicTryCatch.TryCatchLogla(() => { _uow.GenericRepository <DepoDto>().Update(depo); result = _uow.Commit(); _uow.Dispose(); }, MethodBase.GetCurrentMethod().Name); return(result); }
public void DepoKaydet() { bllDepo = new DepoBll(); DepoDto depoDto = new DepoDto() { DepoAdi = txtDepoAdi.Text, DepoKodu = txtDepoKodu.Text, AktifMi = true }; CudEnums enums = bllDepo.DepoEkle(depoDto); FormHelpers.ShowMessage(enums); DepolariGetir(); FormHelpers.ClearTextboxes(this.Controls); }
/// <summary> /// DepoDto tipinde entity alır ve veritabanında deaktive eder. /// Hata alması durumunda CudEnums döner. /// </summary> /// <param name="depo"></param> /// <returns></returns> public CudEnums DepoSil(DepoDto depo) { CudEnums enums = CudEnums.VeritabaniHatasi; DynamicTryCatch.TryCatchLogla(() => { depo.AktifMi = false; int result = dalDepo.DepoDuzenle(depo); if (result > 0) { enums = CudEnums.IslemBasarili; } }, MethodBase.GetCurrentMethod().Name); return(enums); }
public async Task <DepoDto> CreateAsync(DepoDto dto) { await _unitOfWork.Depos.GuardForDuplicateDepoName(dto.Name); var depo = new Depo(dto.Name, dto.OrganizationId, dto.StationId); if (dto.Location != null) { var location = new Location(dto.Location.Latitude, dto.Location.Longitude); depo.UpdateLocation(location); } await _unitOfWork.CompleteAsync(ctx => ctx.Depos.AddAsync(depo)); dto.Id = depo.Id; return(dto); }
private void DuzenleToolStripMenuItem_Click(object sender, EventArgs e) { dtoDepo = new DepoDto(); if (gridView1.SelectedRowsCount == 1) { düzenlemeyiKaydetToolStripMenuItem.Visible = true; dtoDepo = (DepoDto)gridView1.GetRow(gridView1.FocusedRowHandle); txtDepoAdi.Text = dtoDepo.DepoAdi; txtDepoKodu.Text = dtoDepo.DepoKodu; } else if (gridView1.SelectedRowsCount > 1) { FormHelpers.ShowWarning("Aynı anda tek satırda düzenleme yapabilirsiniz!"); } else { FormHelpers.ShowWarning("Düzenlemek istediğiniz depoyu seçiniz!"); } }
/// <summary> /// Depo tipinde entity alır ve DepoDAL nesnesine gönderir. /// Hata alması durumunda CudEnums döner. /// </summary> /// <param name="depo"></param> /// <returns></returns> public CudEnums DepoEkle(DepoDto depo) { CudEnums enums = CudEnums.EksikParametreHatasi; DynamicTryCatch.TryCatchLogla(() => { if (!string.IsNullOrEmpty(depo.DepoAdi) && !string.IsNullOrEmpty(depo.DepoKodu)) { int result = dalDepo.DepoEkle(depo); if (result > 0) { enums = CudEnums.IslemBasarili; } else { enums = CudEnums.VeritabaniHatasi; } } }, MethodBase.GetCurrentMethod().Name); return(enums); }
public DatabaseInitilize() { context = new StokContext(); _uow = new UnitOfWorkBase(context); // Procedure Initilize #region Kullanici Procedure string insertKullaniciProducedure = @"CREATE PROCEDURE [dbo].[Insert_Kullanici] @KullaniciAdi NVARCHAR(25), @Isim NVARCHAR(20), @Soyisim NVARCHAR(20), @Sifre NVARCHAR(35), @AktifMi BIT AS BEGIN BEGIN TRANSACTION [insert_tran]; BEGIN TRY INSERT INTO dbo.Kullanicilar ( KullaniciAdi, Isim, Soyisim, Sifre, AktifMi ) VALUES (@KullaniciAdi, @Isim, @Soyisim, @Sifre, @AktifMi); COMMIT TRANSACTION [insert_tran]; RETURN 1; END TRY BEGIN CATCH ROLLBACK TRANSACTION [insert_tran]; RETURN -1; END CATCH; END;"; _uow.GenericRepository <KullaniciDto>().SqlQuery(insertKullaniciProducedure); #endregion #region Depo Procedure string InsertDepoProcedure = @"CREATE PROCEDURE [dbo].[Insert_Depo] @DepoKodu NVARCHAR(15), @DepoAdi NVARCHAR(25), @AktifMi BIT AS BEGIN BEGIN TRANSACTION [insert_tran]; BEGIN TRY INSERT INTO dbo.Depolar ( DepoKodu, DepoAdi, AktifMi ) VALUES ( @DepoKodu, -- DepoKodu - nvarchar(15) @DepoAdi, -- DepoAdi - nvarchar(max) @AktifMi -- AktifMi - bit ); COMMIT TRANSACTION [insert_tran]; RETURN 1; END TRY BEGIN CATCH ROLLBACK TRANSACTION [insert_tran]; RETURN -1; END CATCH; END;"; _uow.GenericRepository <DepoDto>().SqlQuery(InsertDepoProcedure); #endregion #region Stok Hareketleri Procedure string insertStokHareketleriProcedure = @"CREATE PROCEDURE [dbo].[Insert_StokHareketleri] @Fisno NVARCHAR(15), @Miktar INT, @HareketDurumId INT, @StokKartId INT, @KayitTarihi DATETIME, @KullaniciId INT, @AktifMi BIT AS BEGIN BEGIN TRANSACTION [insert_tran]; BEGIN TRY INSERT INTO dbo.Stok_Hareketleri ( FisNo, Miktar, HareketDurumId, StokKartId, KayitTarihi, KullaniciId, AktifMi ) VALUES ( @Fisno, @Miktar, @HareketDurumId, @StokKartId, @KayitTarihi, @KullaniciId, @AktifMi ) COMMIT TRANSACTION [insert_tran]; RETURN 1; END TRY BEGIN CATCH ROLLBACK TRANSACTION [insert_tran]; RETURN -1; END CATCH; END;"; _uow.GenericRepository <StokHareketleriDto>().SqlQuery(insertStokHareketleriProcedure); string queryForeignKey = @"ALTER TABLE Stok_Hareketleri ADD FOREIGN KEY(StokKartId) REFERENCES Stok_Kartlari(StokKartId); "; _uow.GenericRepository <StokHareketleriDto>().SqlQuery(queryForeignKey); #endregion #region Stok Kartları Procedure string insertStokKartlariProcedure = @"CREATE PROCEDURE [dbo].[Insert_StokKartlari] @StokKodu NVARCHAR(15), @StokAdi NVARCHAR(50), @Kdv INT, @Fiyat DECIMAL(18,2), @Aciklama NVARCHAR(MAX), @Resim VARBINARY(MAX), @DepoId INT, @KayitTarihi DATETIME, @KullaniciId INT, @Aktif BIT AS BEGIN BEGIN TRANSACTION [insert_tran]; BEGIN TRY INSERT INTO dbo.Stok_Kartlari ( StokKodu, StokAdi, Kdv, Fiyat, Aciklama, Resim, DepoId, KayitTarihi, KullaniciId, AktifMi ) VALUES ( @StokKodu, -- StokKodu - nvarchar(15) @StokAdi, -- StokAdi - nvarchar(50) @Kdv, -- Kdv - int @Fiyat, -- Fiyat - decimal(18, 2) @Aciklama, -- Aciklama - nvarchar(max) @Resim, -- Resim - varbinary(max) @DepoId, -- DepoId - int @KayitTarihi, -- KayitTarihi - datetime @KullaniciId, -- KullaniciId - int @Aktif -- AktifMi - bit ) COMMIT TRANSACTION [insert_tran]; RETURN 1; END TRY BEGIN CATCH ROLLBACK TRANSACTION [insert_tran]; RETURN -1; END CATCH; END;"; _uow.GenericRepository <StokKartiDto>().SqlQuery(insertStokKartlariProcedure); #endregion #region Stok Hareket Tipi Procedure string insertStokHareketTipiProcedure = @"CREATE PROCEDURE [dbo].[Insert_Stok_Hareket_Tipi] @StokHareketTipi NVARCHAR(10), @AktifMi Bit AS BEGIN BEGIN TRANSACTION [insert_tran]; BEGIN TRY INSERT INTO dbo.Stok_Hareket_Tipi ( HareketTipi, AktifMi ) VALUES ( @StokHareketTipi, -- HareketTipi - nvarchar(10) @AktifMi -- AktifMi - bit ) COMMIT TRANSACTION [insert_tran]; RETURN 1; END TRY BEGIN CATCH ROLLBACK TRANSACTION [insert_tran]; RETURN -1; END CATCH; END;"; _uow.GenericRepository <StokHareketTipiDto>().SqlQuery(insertStokHareketTipiProcedure); #endregion #region Kullanıcı Olustur PasswordHash passwordHash = new PasswordHash(); KullaniciDto kullanici = new KullaniciDto() { Isim = "Yusuf", Soyisim = "Güvençli", KullaniciAdi = "YusufGuvencli", Sifre = passwordHash.Hash("123456"), AktifMi = true }; KullaniciDal kullaniciDLL = new KullaniciDal(); kullaniciDLL.KullaniciEkle(kullanici); #endregion #region Stok Hareket Tipi Olustur StokHareketTipiDto stokHareketTipi; StokHareketTipiDal stokHareketDal; string[] hareketler = new string[] { "Giriş", "Çıkış" }; for (int i = 0; i < hareketler.Length; i++) { stokHareketTipi = new StokHareketTipiDto(); stokHareketTipi.HareketTipi = hareketler[i]; stokHareketTipi.AktifMi = true; stokHareketDal = new StokHareketTipiDal(); stokHareketDal.StokHareketTipiEkle(stokHareketTipi); } #endregion #region Depo Olustur DepoDto depoDto = new DepoDto() { DepoAdi = "Test Deposu", DepoKodu = "00001", AktifMi = true }; DepoDal depoDal = new DepoDal(); depoDal.DepoEkle(depoDto); #endregion #region Stok Hareketleri View string stokHareketView = @"CREATE VIEW [dbo].[vw_StokHareketleri] AS SELECT H.HareketId, H.FisNo, H.Miktar, tip.HareketDurumId, tip.HareketTipi, K.StokKartId, K.StokKodu, K.StokAdi, H.KayitTarihi FROM dbo.Stok_Hareketleri AS H INNER JOIN dbo.Stok_Kartlari AS K ON K.StokKartId = H.StokKartId INNER JOIN dbo.Stok_Hareket_Tipi AS tip ON tip.HareketDurumId = H.HareketDurumId WHERE (H.AktifMi = 1)"; _uow.GenericRepository <StokHareketleriDto>().SqlQuery(stokHareketView); #endregion #region Stok Hareket Raporu View string stokHareketRaporu = @"CREATE VIEW [dbo].[vw_StokHareketRaporu] AS SELECT H.FisNo, H.Miktar, H.KayitTarihi AS HareketTarihi, tip.HareketTipi, K.StokKodu, K.StokAdi, K.Aciklama, K.KayitTarihi AS StokKayitTarihi FROM dbo.Stok_Hareketleri AS H INNER JOIN dbo.Stok_Hareket_Tipi AS tip ON tip.HareketDurumId = H.HareketDurumId INNER JOIN dbo.Stok_Kartlari AS K ON K.StokKartId = H.StokKartId"; _uow.GenericRepository <StokHareketleriRaporDto>().SqlQuery(stokHareketRaporu); #endregion #region string stokDurumRaporu = @"CREATE VIEW [dbo].[vw_StokDurumRaporu] AS WITH cte AS (SELECT StokKartId, (SELECT SUM(Miktar) AS Expr1 FROM dbo.Stok_Hareketleri AS H1 WHERE (HareketDurumId = 1) AND (StokKartId = H.StokKartId) AND (AktifMi = 1)) AS ToplamGiris, (SELECT SUM(Miktar) AS Expr1 FROM dbo.Stok_Hareketleri AS H1 WHERE (HareketDurumId = 2) AND (StokKartId = H.StokKartId) AND (AktifMi = 1)) AS ToplamCikis FROM dbo.Stok_Hareketleri AS H GROUP BY StokKartId) SELECT K.StokAdi, K.StokKodu, D.DepoAdi, D.DepoKodu, ISNULL(cte_1.ToplamGiris, 0) AS MevcutStok, ISNULL(cte_1.ToplamCikis, 0) AS CikanStok FROM cte AS cte_1 INNER JOIN dbo.Stok_Kartlari AS K ON K.StokKartId = cte_1.StokKartId INNER JOIN dbo.Depolar AS D ON D.DepoId = K.DepoId"; _uow.GenericRepository <StokHareketView>().SqlQuery(stokDurumRaporu); #endregion }
public async Task <Result <DepoDto> > Update([FromBody] DepoDto dto) { var depo = await _depoService.UpdateAsync(dto); return(Result <DepoDto> .Success(data : depo)); }