Esempio n. 1
0
 public virtual async Task UpdateAsync(ShopFacilitiesRequest shopFacilitiesRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (shopFacilitiesRequest == null)
     {
         throw new ArgumentNullException(nameof(shopFacilitiesRequest));
     }
     await Store.UpdateAsync(_mapper.Map <ShopFacilities>(shopFacilitiesRequest), cancellationToken);
 }
Esempio n. 2
0
        public virtual async Task <ShopFacilitiesResponse> CreateAsync(ShopFacilitiesRequest shopFacilitiesRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (shopFacilitiesRequest == null)
            {
                throw new ArgumentNullException(nameof(shopFacilitiesRequest));
            }
            var facilities = await Store.CreateAsync(_mapper.Map <ShopFacilities>(shopFacilitiesRequest), cancellationToken);

            return(_mapper.Map <ShopFacilitiesResponse>(facilities));
        }
Esempio n. 3
0
 public virtual async Task SaveAsync(UserInfo user, string buildingId, ShopFacilitiesRequest shopFacilitiesRequest, CancellationToken cancellationToken = default(CancellationToken))
 {
     if (user == null)
     {
         throw new ArgumentNullException(nameof(user));
     }
     if (shopFacilitiesRequest == null)
     {
         throw new ArgumentNullException(nameof(shopFacilitiesRequest));
     }
     await Store.SaveAsync(_mapper.Map <SimpleUser>(user), buildingId, _mapper.Map <ShopFacilities>(shopFacilitiesRequest), cancellationToken);
 }
Esempio n. 4
0
        public async Task <ResponseMessage> PutShopsFacilities(UserInfo user, [FromRoute] string buildingId, [FromRoute]  string shopId, [FromBody] ShopFacilitiesRequest shopFacilitiesRequest)
        {
            Logger.Trace($"用户{user?.UserName ?? ""}({user?.Id ?? ""})修改楼盘设施信息(PutShopsFacilities):\r\n请求参数为:\r\n" + (shopFacilitiesRequest != null ? JsonHelper.ToJson(shopFacilitiesRequest) : ""));

            ResponseMessage response = new ResponseMessage();

            if (!ModelState.IsValid || shopFacilitiesRequest.Id != shopId)
            {
                response.Code    = ResponseCodeDefines.ModelStateInvalid;
                response.Message = ModelState.GetAllErrors();
                Logger.Warn($"用户{user?.UserName ?? ""}({user?.Id ?? ""})修改楼盘设施信息(PutShopsFacilities)模型验证失败:\r\n{response.Message ?? ""},\r\n请求参数为:\r\n" + (shopFacilitiesRequest != null ? JsonHelper.ToJson(shopFacilitiesRequest) : ""));
                return(response);
            }
            try
            {
                await _shopFacilitiesManager.SaveAsync(user, buildingId, shopFacilitiesRequest, HttpContext.RequestAborted);

                //var dictionaryGroup = await _shopFacilitiesManager.FindByIdAsync(buildingId, HttpContext.RequestAborted);
                //if (dictionaryGroup == null)
                //{
                //    await _shopFacilitiesManager.CreateAsync(shopFacilitiesRequest, HttpContext.RequestAborted);
                //}
                //await _shopFacilitiesManager.UpdateAsync(shopFacilitiesRequest, HttpContext.RequestAborted);
            }
            catch (Exception e)
            {
                response.Code    = ResponseCodeDefines.ServiceError;
                response.Message = e.ToString();
                Logger.Error($"用户{user?.UserName ?? ""}({user?.Id ?? ""})修改楼盘设施信息(PutShopsFacilities)请求失败:\r\n{e.ToString()},\r\n请求参数为:\r\n" + (shopFacilitiesRequest != null ? JsonHelper.ToJson(shopFacilitiesRequest) : ""));
            }
            return(response);
        }