Exemplo n.º 1
0
        public async Task <BaseResponse <int> > CreateAsync(CompanySql model, int createBy)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var p = AddOutputParam("id");
                    p.Add("fullname", model.FullName);
                    p.Add("checkdate", model.CheckDate);
                    p.Add("note", model.LastNote);
                    p.Add("createdtime", DateTime.Now);
                    p.Add("createdby", createBy);
                    p.Add("TaxNumber", model.TaxNumber);
                    p.Add("PartnerId", model.PartnerId);
                    p.Add("CatType", model.CatType);
                    await con.ExecuteAsync("sp_InsertCompany", p, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(p.Get <int>("id")));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Exemplo n.º 2
0
        public async Task <BaseResponse <bool> > UpdateAsync(CompanySql model, int updateBy)
        {
            var p = new DynamicParameters();

            p.Add("id", model.Id);
            p.Add("fullname", model.FullName);
            p.Add("checkdate", model.CheckDate);
            p.Add("status", model.Status);
            p.Add("note", string.IsNullOrWhiteSpace(model.LastNote) ? null : model.LastNote);
            p.Add("TaxNumber", model.TaxNumber);
            p.Add("CatType", model.CatType);
            p.Add("updatedtime", DateTime.Now);
            p.Add("updatedby", updateBy);
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_UpdateCompany", p, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }