Beispiel #1
0
        public override async Task <int> HandleCommand(DeleteGLNCommand request, CancellationToken cancellationToken)
        {
            GLNModel gln = null;

            if (request.Model == 0)
            {
                throw new BusinessException("GLN.NotSelected");
            }
            else
            {
                gln = await glnQueries.GetByIdAsync(request.Model);

                if (gln == null)
                {
                    throw new BusinessException("GLN.NotSelected");
                }
            }

            var rs = -1;

            using (var conn = DALHelper.GetConnection())
            {
                conn.Open();
                using (var trans = conn.BeginTransaction())
                {
                    try
                    {
                        gln.IsDeleted    = true;
                        gln.ModifiedDate = DateTime.Now;
                        gln.ModifiedBy   = request.LoginSession.Id;

                        if (await glnRepository.UpdateAsync(gln) > 0)
                        {
                            rs = 0;
                        }
                    }
                    catch (Exception ex)
                    {
                        throw ex;
                    }
                    finally
                    {
                        if (rs == 0)
                        {
                            trans.Commit();
                        }
                        else
                        {
                            try { trans.Rollback(); } catch { }
                        }
                    }
                }
            }

            return(rs);
        }
Beispiel #2
0
        public async Task <APIResult> GetById(int id)
        {
            var rs = await glnQueries.GetByIdAsync(id);

            return(new APIResult()
            {
                Result = 0,
                Data = rs
            });
        }