Ejemplo n.º 1
0
        public async Task <BaseResponse <bool> > UpdateAsync(GroupEditModel model, string parentSequenceCode, int orgId)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var result = await con.ExecuteAsync("sp_Group_Update",
                                                        new
                    {
                        Id        = model.Id,
                        parentId  = model.ParentId,
                        LeaderId  = model.LeaderId,
                        ShortName = model.ShortName,
                        Name      = model.Name,
                        parentSequenceCode,
                        orgId,
                        memberIds = string.Join(',', model.MemberIds)
                    },
                                                        commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <bool> .Create(false, GetException(ex)));
            }
        }
Ejemplo n.º 2
0
        public async Task <BaseResponse <int> > CreateAsync(UserSql model)
        {
            var p = AddOutputParam("id");

            p.Add("code", model.Code);
            p.Add("userName", model.UserName);
            p.Add("password", model.Password);
            p.Add("fullName", model.FullName);
            p.Add("phone", model.Phone);
            p.Add("roleId", model.RoleId);
            p.Add("email", model.Email);
            p.Add("createdby", model.CreatedBy);
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_Employee_InsertUser_v2", p, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(p.Get <int>("id")));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Ejemplo n.º 3
0
        public async Task <BaseResponse <int> > CreateAsync(CheckDupAddSql model, int createdBy)
        {
            //var par = GetParams(model, new string[] {
            //    nameof(model.UpdatedBy),
            //    nameof(model.UpdatedTime),
            //    nameof(model.CreatedTime),
            //    nameof(model.CreatedBy)

            //}, "Id");
            //par.Add("CreatedBy", createdBy);
            try
            {
                using (var con = GetConnection())
                {
                    var pars = GetParams(model, new string[] {
                        nameof(model.CreatedTime),
                        nameof(model.UpdatedTime),
                        nameof(model.UpdatedBy),
                        nameof(model.CreatedBy)
                    }, nameof(model.Id));
                    pars.Add("CreatedBy", createdBy);

                    await con.ExecuteAsync("sp_InsertCustomer_v2", pars, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(pars.Get <int>(nameof(model.Id))));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Ejemplo n.º 4
0
        public async Task <BaseResponse <int> > Add(ProfileFileAddSql model)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var p = AddOutputParam("Id");
                    p.Add("FileKey", model.FileKey);
                    p.Add("FilePath", model.FilePath);
                    p.Add("Folder", model.Folder);
                    p.Add("FileName", model.FileName);
                    p.Add("ProfileId", model.ProfileId);
                    p.Add("ProfileTypeId", model.ProfileTypeId);
                    p.Add("GuidId", model.GuidId);
                    p.Add("FileId", model.FileId);
                    await con.ExecuteAsync("sp_TAI_LIEU_HS_Them_v2", p,
                                           commandType : CommandType.StoredProcedure);

                    var id = p.Get <int>("Id");
                    return(BaseResponse <int> .Create(id));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Ejemplo n.º 5
0
        public async Task <BaseResponse <int> > CreateAsync(ProfileAddSql model, int createdBy)
        {
            var par = GetParams(model, new string[] {
                nameof(model.UpdatedBy),
                nameof(model.UpdatedTime),
                nameof(model.CreatedTime),

                nameof(model.CreatedBy),
                nameof(model.Ma_Ho_So)
            }, "id");

            par.Add("CreatedBy", createdBy);
            try
            {
                using (var _con = GetConnection())
                {
                    await _con.ExecuteAsync("sp_HO_SO_Them_v2", par, commandType : CommandType.StoredProcedure);

                    var id = par.Get <int>("id");
                    return(BaseResponse <int> .Create(id));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Ejemplo n.º 6
0
        public async Task <BaseResponse <bool> > UpdateAsync(ProfileAddSql model, int profileId, int updatedBy)
        {
            model.ID = profileId;
            var par = GetParams(model, new string[] {
                nameof(model.CreatedBy),
                nameof(model.Ma_Ho_So),
                nameof(model.UpdatedBy),
                nameof(model.Ghi_Chu),
                nameof(model.CreatedTime),
                nameof(model.UpdatedTime),
                nameof(model.IsDeleted)
            });

            par.Add("UpdatedBy", updatedBy);
            try
            {
                using (var _con = GetConnection())
                {
                    await _con.ExecuteAsync("sp_update_HO_SO_v2", par, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 7
0
        public async Task <BaseResponse <bool> > UpdateAsync(CheckDupAddSql model, int updateBy)
        {
            var pars = GetParams(model, new string[]
            {
                nameof(model.CreatedBy),
                nameof(model.CreatedTime),
                nameof(model.UpdatedTime),
                nameof(model.UpdatedBy),
            });

            pars.Add(nameof(model.UpdatedBy), updateBy);
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_UpdateCustomer_v2", pars, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 8
0
        public async Task <BaseResponse <int> > CreateDraftProfileAsync(MCredit_TempProfile model)
        {
            try
            {
                model.Id = 0;
                var param = GetParams(model, ignoreKey: new string[]
                {
                    nameof(model.CreatedTime),
                    nameof(model.UpdatedTime),
                    nameof(model.isAddress),
                    nameof(model.isInsur),
                    nameof(model.MCId)
                }, outputParam: "Id");

                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_insert_MCredit_TempProfile", param, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(param.Get <int>("Id")));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
Ejemplo n.º 9
0
 public async Task <BaseResponse <bool> > ImportAsync(List <CourierSql> models, int groupId = 0)
 {
     try
     {
         using (var con = GetConnection())
         {
             foreach (var model in models)
             {
                 var param = GetParams(model, ignoreKey: new string[] {
                     nameof(model.CreatedTime),
                     nameof(model.Id),
                     nameof(model.UpdatedTime),
                     nameof(model.UpdatedBy),
                     nameof(model.AssigneeIds)
                 });
                 await con.ExecuteAsync("sp_Courier_Import", param, commandType : CommandType.StoredProcedure);
             }
         }
         return(BaseResponse <bool> .Create(true));
     }
     catch (Exception e)
     {
         return(BaseResponse <bool> .Create(false, GetException(e)));
     }
 }
Ejemplo n.º 10
0
        public async Task <BaseResponse <bool> > UpdateDraftProfileAsync(MCredit_TempProfile model)
        {
            var param = GetParams(model, ignoreKey: new string[]
            {
                nameof(model.CreatedTime),
                nameof(model.UpdatedTime),
                nameof(model.CreatedBy),
                nameof(model.MCId),
                nameof(model.isAddress),
                nameof(model.isInsur)
            });

            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_update_MCredit_TempProfile", param, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 11
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)));
            }
        }
Ejemplo n.º 12
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)));
            }
        }
Ejemplo n.º 13
0
        public BaseResponse Process(BaseRequest baseRequest)
        {
            var request = baseRequest as Request20001;

            var merchant = this._merchantService.Get(c => c.MerchantNo == request.MerchantNo);

            if (merchant.IsNull())
            {
                return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "商户不存在"));
            }
            var order = this._payOrderService.Get(c => c.MerchantOrderNo == request.MerchantOrderNo && c.MerchantId == merchant.MerchantId);

            if (order.IsNull())
            {
                return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "查无此订单"));
            }
            return(BaseResponse.Create(ApiEnum.ResponseCode.处理成功, new Response20001
            {
                MerchantNo = merchant.MerchantNo,
                MerchantOrderNO = order.MerchantOrderNo,
                OrderNO = order.OrderNo,
                OrderAmount = order.OrderAmount,
                OrderTime = order.MerchantOrderTime,
                PayStatus = order.PayStatus,
                PayResult = Enum.GetName(typeof(Max.Models.Payment.Common.Enums.PayStatus), order.PayStatus)
            }));
        }
Ejemplo n.º 14
0
        public async Task <BaseResponse <int> > CreateAsync(GroupCreateModel model, string parentSequenceCode, int orgId, int createdBy)
        {
            try
            {
                var pars = new DynamicParameters();
                pars.Add("Id", dbType: DbType.Int32, direction: ParameterDirection.Output);
                pars.Add("parentId", model.ParentId);
                pars.Add("LeaderId", model.LeaderId);
                pars.Add("ShortName", model.ShortName);
                pars.Add("Name", model.Name);
                pars.Add("parentSequenceCode", parentSequenceCode);
                pars.Add("orgId", orgId);
                pars.Add("createdBy", createdBy);
                pars.Add("memberIds", string.Join(',', model.MemberIds));
                using (var con = GetConnection())
                {
                    var result = await con.ExecuteAsync("sp_Group_Create",
                                                        pars,
                                                        commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(pars.Get <int>("Id")));
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <int> .Create(0, GetException(ex)));
            }
        }
Ejemplo n.º 15
0
 protected BaseResponse <T> ToResponse <T>(T data, string error = null)
 {
     if (!string.IsNullOrWhiteSpace(error))
     {
         AddError(error);
         return(BaseResponse <T> .Create(data, error));
     }
     return(BaseResponse <T> .Create(data));
 }
        protected BaseResponse GenerateValidationExceptionResponse()
        {
            var index = 1;
            var exceptionMessageBuilder = new StringBuilder();

            ModelState.Keys.Where(key => key.StartsWith("request")).ForEach(key =>
                                                                            exceptionMessageBuilder.Append($"{index++}) {ModelState[key].Errors.First().ErrorMessage} "));
            var exceptionMessage = IsVisibleExceptionRemoute ? exceptionMessageBuilder.ToString() : "bad request";

            return(BaseResponse.Create(500, exceptionMessage));
        }
Ejemplo n.º 17
0
        public ActionResult Get()
        {
            var todo = _todoService.GetAll();

            if (todo == null)
            {
                return(new JsonResult(BaseResponse.Create(HttpStatusCode.NotFound, todo, "Hiç kayıt bulunamadı")));
            }

            return(new JsonResult(BaseResponse.Create(HttpStatusCode.OK, todo, "")));
        }
Ejemplo n.º 18
0
        public BaseResponse Process(BaseRequest baseRequest)
        {
            try
            {
                var request = baseRequest as Request10001;
                //商户验证
                var merchant = this._merchantService.Get(c => c.MerchantNo == request.MerchantNo);
                if (merchant.IsNull())
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "商户不存在", null, 0));
                }
                if (merchant.Status != (int)Max.Models.Payment.Common.Enums.CommonStatus.正常)
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "商户不可用", null, 0));
                }

                //支付方式验证
                var payProduct = this._payProductService.Get(c => c.ServiceCode == request.PayType);
                if (payProduct.IsNull() || payProduct.Status != (int)Max.Models.Payment.Common.Enums.CommonStatus.正常)
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "支付方式{0}不可用".Fmt(request.PayType), null, 0));
                }

                //商户是否开通该支付方式
                var merchantPayProduct = this._merchantPayProductService.Get(c => c.MerchantId == merchant.MerchantId && c.ServiceId == payProduct.ServiceId);
                if (merchantPayProduct.IsNull() || merchantPayProduct.Status != (int)Max.Models.Payment.Common.Enums.CommonStatus.正常)
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "商户未开通该支付方式", null, 0));
                }

                //支付路由验证
                var payChannel = this._payChannelService.Get(c => c.ChannelId == merchantPayProduct.PayChannelId);
                if (payChannel.IsNull() || payChannel.Status != (int)Max.Models.Payment.Common.Enums.CommonStatus.正常)
                {
                    return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, "支付渠道不可用", null, 0));
                }

                //订单入库
                var order = CreateOrder(request, merchant, payProduct, payChannel, merchantPayProduct);

                return(BaseResponse.Create(ApiEnum.ResponseCode.处理成功, new Response10001
                {
                    MerchantOrderNO = request.MerchantOrderNo,
                    OrderNO = order.OrderNo,
                    Amount = order.OrderAmount,
                    PayUrl = "http://localhost:2162?orderid={0}".Fmt(order.OrderId)
                }));
            }
            catch (Exception ex)
            {
                return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, ex.ToJson(), null, 0));
            }
        }
Ejemplo n.º 19
0
        public async Task <BaseResponse <MCredit_TempProfile> > GetTemProfileByMcIdAsync(string id)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var result = await con.QueryFirstOrDefaultAsync <MCredit_TempProfile>("sp_MCredit_TempProfile_GetByMCId", new { id }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <MCredit_TempProfile> .Create(result));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <MCredit_TempProfile> .Create(null, GetException(e)));
            }
        }
Ejemplo n.º 20
0
        public async Task <BaseResponse <bool> > UpdateTempProfileStatusAsync(int profileId, int status)
        {
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_MCredit_UpdateStatusFromMC", new { profileId, status }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 21
0
        public async Task <BaseResponse <ProfileDetail> > GetByIdAsync(int profileId)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var result = await con.QueryFirstOrDefaultAsync <ProfileDetail>("sp_HO_SO_LayChiTiet_v2", new { profileId }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <ProfileDetail> .Create(result));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <ProfileDetail> .Create(null, GetException(e)));
            }
        }
Ejemplo n.º 22
0
        public async Task <BaseResponse <bool> > DeleteByIdAsync(int id, int updateBy)
        {
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_Product_Delete", new { id, updateBy }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 23
0
        public async Task <BaseResponse <int> > AddMCredit(MCProfileFileSqlModel model)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var p = GetParams(model, outputParam: "Id");
                    await con.ExecuteAsync("sp_TAI_LIEU_HS_Them_v2", p,
                                           commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(p.Get <int>("Id")));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }
        public async Task <BaseResponse <bool> > CreateAsync(int profileId)
        {
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_HO_SO_DUYET_XEM_Them", new { ID = profileId }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                await _rpLog.InsertLogFromException($"CreateAsync-ProfileNotification-{profileId}", e);

                return(BaseResponse <bool> .Create(false));
            }
        }
Ejemplo n.º 25
0
        public BaseResponse Process(BaseRequest baseRequest)
        {
            try
            {
                var dicRequest = CreatePayRequest(baseRequest.Order, baseRequest.PayChannel);

                HttpWebHelper http        = new Framework.Utility.HttpWebHelper();
                var           responseStr = http.Post("http://gateway.jbpay.net/api/gateway", dicRequest, Encoding.UTF8, Encoding.UTF8);

                return(BaseResponse.Create(ApiEnum.ResponseCode.处理成功, new Response10001
                {
                    MerchantOrderNO = baseRequest.Order.OrderId,
                    PayUrl = responseStr
                }));
            }
            catch (Exception ex)
            {
                return(BaseResponse.Create(ApiEnum.ResponseCode.处理失败, ex.ToJson(), null, 0));
            }
        }
Ejemplo n.º 26
0
        public async Task <BaseResponse <bool> > UpdateMCIdAsync(int id, string mcId, int updatedBy)
        {
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_MCProfile_UpdateMcId", new
                    {
                        id,
                        mcId,
                        updatedBy
                    }, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 27
0
        public async Task Invoke(HttpContext context)
        {
            var currentBody = context.Response.Body;

            using (var memoryStream = new MemoryStream())
            {
                //set the current response to the memorystream.
                context.Response.Body = memoryStream;

                await _next(context);

                //reset the body
                context.Response.Body = currentBody;
                memoryStream.Seek(0, SeekOrigin.Begin);

                var readToEnd = new StreamReader(memoryStream).ReadToEnd();
                var objResult = JsonConvert.DeserializeObject(readToEnd);
                var result    = BaseResponse.Create((HttpStatusCode)context.Response.StatusCode, objResult, null);
                await context.Response.WriteAsync(JsonConvert.SerializeObject(result));
            }
        }
Ejemplo n.º 28
0
        public async Task <BaseResponse <bool> > DeleteAsync(int userId, int deleteId)
        {
            var p = new DynamicParameters();

            p.Add("userId", userId);

            p.Add("deleteId", deleteId);
            try
            {
                using (var con = GetConnection())
                {
                    await con.ExecuteAsync("sp_Employee_Delete_v3", p, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <bool> .Create(true));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <bool> .Create(false, GetException(e)));
            }
        }
Ejemplo n.º 29
0
        public async Task <BaseResponse <string> > GetParentSequenceCodeAsync(int groupId)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var result = await con.QueryFirstOrDefaultAsync <string>("sp_NHOM_LayChuoiMaChaCuaMaNhom",
                                                                             new
                    {
                        MaNhom = groupId
                    },
                                                                             commandType : CommandType.StoredProcedure);

                    return(BaseResponse <string> .Create(result));
                }
            }
            catch (Exception ex)
            {
                return(BaseResponse <string> .Create("0", GetException(ex)));
            }
        }
Ejemplo n.º 30
0
        public async Task <BaseResponse <int> > CreateAsync(CourierSql model, int groupId = 0)
        {
            try
            {
                using (var con = GetConnection())
                {
                    var param = GetParams(model, ignoreKey: new string[] {
                        nameof(model.CreatedTime),
                        nameof(model.UpdatedTime),
                        nameof(model.UpdatedBy),
                        nameof(model.AssigneeIds)
                    }, outputParam: "Id");
                    await con.ExecuteAsync("sp_InsertHosoCourrier", param, commandType : CommandType.StoredProcedure);

                    return(BaseResponse <int> .Create(param.Get <int>("Id")));
                }
            }
            catch (Exception e)
            {
                return(BaseResponse <int> .Create(0, GetException(e)));
            }
        }