Exemplo n.º 1
0
        /// <summary>
        /// 修改
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public IActionResult Modify([FromBody] ClientInfo model)
        {
            try
            {
                if (_clientInfoRepository.Count(e => e.ClientName == model.ClientName && e.Id != model.Id && e.UserId == CurrentUser.Id && e.IsDel == 0) > 0)
                {
                    return(JsonError("客户名重复"));
                }

                var oldModel = _clientInfoRepository.GetSingle(model.Id);
                oldModel.UpdateTime      = DateTime.Now;
                oldModel.ProvinceName    = model.ProvinceName;
                oldModel.ProvinceCode    = model.ProvinceCode;
                oldModel.DetailedAddress = model.DetailedAddress;
                oldModel.CountyName      = model.CountyName;
                oldModel.CountyCode      = model.CountyCode;
                oldModel.ClientPhone     = model.ClientPhone;
                oldModel.ClientName      = model.ClientName;
                oldModel.CityName        = model.CityName;
                oldModel.CityCode        = model.CityCode;
                _clientInfoRepository.Update(oldModel);
                return(JsonOk(""));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Gets client info by the specified ip.
 /// </summary>
 /// <param name="ipAddress">The ip address.</param>
 /// <returns></returns>
 public ClientInfo Get(string ipAddress)
 {
     Requires.NotNullOrEmpty(ipAddress, nameof(ipAddress));
     return(_repository.GetSingle(c => c.ClientIpAddress == ipAddress));
 }