Exemplo n.º 1
0
        public async Task <BaseApiResponse> Edit([FromBody] EditRequest request)
        {
            request.CheckNotNull(nameof(request));

            var command = new UpdateOfflineStoreCommand(
                request.Name,
                request.Thumb,
                request.Phone,
                request.Description,
                request.Labels,
                request.Region,
                request.Address,
                request.Persent,
                request.Longitude,
                request.Latitude,
                request.IsLocked)
            {
                AggregateRootId = request.Id
            };

            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }
            return(new BaseApiResponse());
        }
Exemplo n.º 2
0
 public void Handle(ICommandContext context, UpdateOfflineStoreCommand command)
 {
     context.Get <OfflineStore>(command.AggregateRootId).Update(new OfflineStoreInfo(
                                                                    command.Name,
                                                                    command.Thumb,
                                                                    command.Phone,
                                                                    command.Region,
                                                                    command.Address,
                                                                    command.Description,
                                                                    command.Labels,
                                                                    command.Persent,
                                                                    command.Longitude,
                                                                    command.Latitude,
                                                                    command.IsLocked
                                                                    ));
 }
Exemplo n.º 3
0
        public async Task <BaseApiResponse> Edit(EditRequest request)
        {
            request.CheckNotNull(nameof(request));

            var command = new UpdateOfflineStoreCommand(
                request.Name,
                request.Thumb,
                request.Phone,
                request.Description,
                request.Labels,
                request.Region,
                request.Address,
                request.Persent,
                request.Longitude,
                request.Latitude,
                request.IsLocked)
            {
                AggregateRootId = request.Id
            };

            var result = await ExecuteCommandAsync(command);

            if (!result.IsSuccess())
            {
                return(new BaseApiResponse {
                    Code = 400, Message = "命令没有执行成功:{0}".FormatWith(result.GetErrorMessage())
                });
            }

            //添加操作记录
            var currentAdmin = _contextService.GetCurrentAdmin(HttpContext.Current);

            RecordOperat(currentAdmin.AdminId.ToGuid(), "编辑线下店铺", request.Id, request.Name);

            return(new BaseApiResponse());
        }