Esempio n. 1
0
        public Cicada.Core.Ret<int> Add(Dtos.CustomerPostParam item)
        {
            if (item == null || string.IsNullOrWhiteSpace(item.Name)) return new Cicada.Core.Ret<int> { Status = 1, Message = "用户名无效" };

            if (string.IsNullOrWhiteSpace(item.Phone) || !StringUtil.IsPhone(item.Phone)) return new Cicada.Core.Ret<int> { Status = 2, Message = "手机号无效" };

            var newCustomer = new Customer
            {
                Name = item.Name.Trim(),
                Phone = item.Phone,
            };

            if (_dbContext.Set<Customer>().FirstOrDefault(w => w.Name == item.Name) != null) return new Ret<int> { Status = 3, Message = "用户名已存在" };

            _dbContext.Set<Customer>().Add(newCustomer);
            _dbContext.SaveChanges();
            return new Ret<int> { Data = newCustomer .CustomerId};
        }
Esempio n. 2
0
 private bool Equals(Customer first, CustomerRet second)
 {
     return first.CustomerId == second.Id && first.Name == second.Name && first.Phone == second.Phone;
 }