示例#1
0
        private void bbi_Delete_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            BanksDTO oRow = (BanksDTO)gcv_BankDetails.GetFocusedRow();

            if (oRow != null)
            {
                if (get_Question("Kayıt Silinecektir. Onaylıyor musunuz?"))
                {
                    if (oRow.Bid == 0)
                    {
                        _bankDetailsList.Remove(oRow);
                        gridControl1.RefreshDataSource();
                    }
                    else
                    {
                        var result = _repository.Run <BankEntryServices, ActionResponse <BanksDTO> >(x => x.DeleteBank(oRow.Bid));
                        do_refresh();
                    }
                }
            }
        }
示例#2
0
        public ActionResponse <BanksDTO> InsertBank(BanksDTO model)
        {
            ActionResponse <BanksDTO> response = new ActionResponse <BanksDTO>()
            {
                Response     = model,
                ResponseType = ResponseType.Ok
            };

            using (MspDbContext _db = new MspDbContext())
            {
                try
                {
                    if (response.Response.Bid == 0)
                    {
                        _db.Banks.Add(base.Map <BanksDTO, Banks>(model));
                        _db.SaveChanges();
                    }
                    else
                    {
                        var entity = _db.Banks.FirstOrDefault(x => x.Bid == response.Response.Bid);
                        if (entity != null)
                        {
                            _db.Entry(entity).CurrentValues.SetValues(entity);
                            _db.Entry(entity).State = System.Data.Entity.EntityState.Modified;
                        }
                    }
                    _db.SaveChanges();
                }
                catch (Exception e)
                {
                    response.Message      = e.ToString();
                    response.ResponseType = ResponseType.Error;
                }
            }
            return(response);
        }