Пример #1
0
 public object Update(String account, CustomerReq req)
 {
     try
     {
         var result = context.Customer.FirstOrDefault(value => value.Account == account);
         if (result != null)
         {
             result.Account               = req.Account;
             result.Pass                  = req.Pass;
             result.LastName              = req.LastName;
             result.FirstName             = req.FirstName;
             result.DateOfBirth           = req.DateOfBirth;
             result.Gender                = req.Gender;
             result.Address               = req.Address;
             result.PhoneNumberOfCustomer = req.PhoneNumberOfCustomer;
             result.Email                 = req.Email;
             result.AccountTypeID         = req.AccountTypeID;
             result.CreatedDate           = req.CreatedDate;
             result.AccountStatus         = req.AccountStatus;
             result.Note                  = req.Note;
             context.Customer.Update(result);
             context.SaveChanges();
             return(result);
         }
         else
         {
             return("Unable to update: not found ID.");
         }
     }
     catch (Exception ex)
     {
         return(ex.StackTrace);
     }
 }
        public IActionResult CreateCustomer([FromBody] CustomerReq req)
        {
            var res = new SingleRsp();

            res = _svc.CreateCustomer(req);
            return(Ok(res));
        }
Пример #3
0
        /// <summary>
        /// Create new Customer
        /// </summary>
        /// <param name="model">Customer DTO</param>
        /// <returns>Customer DTO</returns>
        public async Task <CustomerWithSecRes> CreateAsync(CustomerReq model)
        {
            Group group = await _context.Groups.SingleOrDefaultAsync(x => x.GroupId == model.GroupId);

            // group not found
            if (group == null)
            {
                throw new AppLogicException("Skupina neexistuje");
            }

            // autogen password
            string password = GeneratePassword();

            // create user
            User user = await _userService.CreateAsync(model.Email, password, UserRoles.Customer);

            //string hash = Encoding.GetEncoding(1252).GetString(user.PasswordHash);
            string secret = BitConverter.ToString(user.PasswordHash).Replace("-", "");

            secret = secret + ":" + user.Email;

            // create customer
            Customer customer = new Customer
            {
                User  = user,
                Group = group
            };

            _context.Customers.Add(customer);
            await _context.SaveChangesAsync();

            return(new CustomerWithSecRes(customer, secret));
        }
Пример #4
0
        public SingleRsp CreateCustomer(CustomerReq req)
        {
            var res = new SingleRsp();

            try
            {
                Customer c = new Customer();
                c.CustomerId          = req.CustomerId;
                c.FirstName           = req.FirstName;
                c.LastName            = req.LastName;
                c.Email               = req.Email;
                c.PhoneNumber         = req.PhoneNumber;
                c.Street              = req.Street;
                c.District            = req.District;
                c.City                = req.City;
                c.CustomerDescription = req.CustomerDescription;

                //
                res      = base.Create(c);
                res.Data = c;
            }
            catch (Exception ex)
            {
                res.SetError(ex.StackTrace);
            }

            return(res);
        }
Пример #5
0
        /// <summary>
        /// Update
        /// </summary>
        /// <param name="m">The model</param>
        /// <returns>Return the result</returns>
        #endregion

        public SingleRsp CreateCustomer(CustomerReq ctm)
        {
            var       res       = new SingleRsp();
            Customers customers = new Customers();

            customers.FullName = ctm.FullName;
            customers.Email    = ctm.Email;
            customers.Phone    = ctm.Phone;
            res = _rep.CreateCustomer(customers);
            return(res);
        }
Пример #6
0
        public string GetCustomerList(CustomerReq req)
        {
            var user = JsonConvert.DeserializeObject <AllInOne_UserInfo>(Session["user"].ToString());
            var r    = AllFunc.Instance.GetCustomerList(req, user);

            if (r.HttpCode == 200)
            {
                Session["GetCustomerListReq"] = JsonConvert.SerializeObject(req);
            }
            return(JsonConvert.SerializeObject(r));
        }
        public SingleRsp UpdateCustomer(CustomerReq cus)
        {
            var      res       = new SingleRsp();
            Customer customers = new Customer();

            customers.CustomerId    = cus.CustomerId;
            customers.CustomerName  = cus.CustomerName;
            customers.CustomerPhone = cus.CustomerPhone;
            customers.CustomerMail  = cus.CustomerMail;
            res = _rep.UpdateCustomer(customers);
            return(res);
        }
Пример #8
0
        public SingleRsp CreateCustomer(CustomerReq customer)
        {
            var res         = new SingleRsp();
            var customerNew = new Customers()
            {
                FullName  = customer.FullName,
                AccountId = customer.AccountId,
                BirthDate = customer.BirthDate,
                Address   = customer.Address,
                HomePhone = customer.HomePhone,
                Notes     = customer.Notes
            };

            res = _rep.CreateCustomer(customerNew);
            return(res);
        }
Пример #9
0
        public object CreateCustomer(CustomerReq req)
        {
            Customer customer = new Customer();

            customer.Account               = req.Account;
            customer.Pass                  = req.Pass;
            customer.LastName              = req.LastName;
            customer.FirstName             = req.FirstName;
            customer.DateOfBirth           = req.DateOfBirth;
            customer.Gender                = req.Gender;
            customer.Address               = req.Address;
            customer.PhoneNumberOfCustomer = req.PhoneNumberOfCustomer;
            customer.Email                 = req.Email;
            customer.CreatedDate           = req.CreatedDate;
            customer.AccountStatus         = req.AccountStatus;
            customer.Note                  = req.Note;
            return(customerRep.Create(customer));
        }
Пример #10
0
        public SingleResponse UpdateCustomer(CustomerReq req)
        {
            //Khởi tạo
            var       result = new SingleResponse();
            Customers cus    = new Customers();

            //Gán
            cus.PhoneNumber = req.PhoneNumber;
            cus.LastName    = req.LastName;
            cus.FirstName   = req.FirstName;
            cus.CusBirthDay = req.CusBirthDay;
            cus.CusEmail    = req.CusEmail;
            cus.CusGender   = req.CusGender;
            cus.CusType     = req.CusType;
            cus.CusNote     = req.CusNote;
            //Sửa
            result      = base.Update(cus);
            result.Data = cus;
            return(result);
        }
Пример #11
0
        public ActionResult <Customers> Create([FromBody] CustomerReq req)
        {
            Customers customer = new Customers()
            {
                CustomerId    = req.CustomerId,
                Password      = req.Password,
                Name          = req.Name,
                Email         = req.Email,
                BirthDate     = req.BirthDate,
                PhoneNumber   = req.PhoneNumber,
                Address       = req.Address,
                AccountNumber = req.AccountNumber,
                RoleId        = 3
            };

            var result = _context.Customers.Add(customer);

            _context.SaveChanges();

            return(Ok());
        }
        public IActionResult UpdateCustomer([FromBody] CustomerReq req)
        {
            var res = _svc.UpdateCustomer(req);

            return(Ok(res));
        }
        public IActionResult CreateCustomer(CustomerReq req)
        {
            var result = customerSvc.CreateCustomer(req);

            return(Ok(result));
        }
Пример #14
0
        /// <summary>
        /// 获取客户列表
        /// </summary>
        /// <param name="req"></param>
        /// <param name="size"></param>
        /// <returns></returns>
        public List <CustomerView> GetList(CustomerReq req, int size, string lastCId)
        {
            var search = req.search ?? "";
            var order  = req.orderField;
            var desc   = Convert.ToBoolean(req.isDesc);
            var index  = Convert.ToInt32(req.pageIndex);

            var orderStr = $"order by {order} ";

            if (desc)
            {
                orderStr += " desc ";
            }
            else
            {
                orderStr += " asc ";
            }
            var dict = new Dictionary <string, string>
            {
                { "@search", $"%{search}%" },
                { "@search2", search },
                { "@lastcid", lastCId },
            };

            var condition = $" 1=1 and (cid1=@lastcid or cid2=@lastcid or cid3=@lastcid or cid4=@lastcid) ";

            var name = req.lastName;

            if (name != null)
            {
                var cid = AllInOne_UserInfoOper.Instance.GetLastCIdByName(name);

                if (cid != null)
                {
                    dict.Add("cid", cid);
                    condition += $" and  (cid1=@cid or cid2=@cid or cid3=@cid or cid4=@cid) ";
                }
                else
                {
                    return(new List <CustomerView>());
                }
            }

            if (!search.IsNullOrEmpty())
            {
                condition += " and (customerName like @search or address like @search or customerNo=@search2 or mobileNo like @search ) ";
            }

            if (req.useState != null)
            {
                condition += $" and useState={req.useState} ";
            }
            if (req.customerType != null)
            {
                condition += $" and customerType={req.customerType}";
            }
            if (req.estateNo != null)
            {
                condition += $" and estateNo='{req.estateNo}'";
            }
            if (req.factoryNo != null)
            {
                condition += $" and factoryNo='{req.factoryNo}'";
            }
            if (req.meterType != null)
            {
                condition += $" and meterTypeNo='{req.meterType}'";
            }
            if (req.operatorName != null)
            {
                condition += $" and Operator='{req.operatorName}'";
            }


            return(SqlHelper.Instance.GvpForCustomerInfo <CustomerView>("CustomerView", @"select customerNo,
customerType,
contractNo,
customerName,
telNo,
mobileNo,
certNo,
estateNo,
estateName,
address,
houseNo,
cellNo,
roomNo,
useState,
defineNo1,
defineNo2,
defineNo3,
remark,
payWay,
bankNo,
bankAuthNo,
accountName,
accountNo,
bankCheck,
buildTime,
editTime,
Operator,
taxNo,
enterpriseNo,
CustTypeName,
useStateName,
payWayName,
bankCheckName,
enterpriseNoName,
bankName,
factoryNo,
meterTypeNo,
factoryName,
meterTypeName,
deviceNo,
communicateNo from CustomerView ", condition, index, size, orderStr, dict));
        }
Пример #15
0
        /// <summary>
        /// 获取客户总数
        /// </summary>
        /// <param name="req"></param>
        /// <returns></returns>
        public int GetCount(CustomerReq req, string lastCId)
        {
            var search = req.search ?? "";
            var dict   = new Dictionary <string, string>
            {
                { "@search", $"%{search}%" },
                { "@search2", search },
                { "@lastcid", lastCId },
            };

            var condition = $" 1=1 and (cid1=@lastcid or cid2=@lastcid or cid3=@lastcid or cid4=@lastcid) ";

            if (!search.IsNullOrEmpty())
            {
                condition += " and (customerName like @search or address like @search or customerNo=@search2 or mobileNo like @search ) ";
            }

            var name = req.lastName;

            if (name != null)
            {
                var cid = AllInOne_UserInfoOper.Instance.GetLastCIdByName(name);

                if (cid != null)
                {
                    dict.Add("cid", cid);
                    condition += $" and  (cid1=@cid or cid2=@cid or cid3=@cid or cid4=@cid) ";
                }
                else
                {
                    return(0);
                }
            }

            if (req.useState != null)
            {
                condition += $" and useState={req.useState} ";
            }
            if (req.customerType != null)
            {
                condition += $" and customerType={req.customerType}";
            }
            if (req.estateNo != null)
            {
                condition += $" and estateNo='{req.estateNo}'";
            }
            if (req.factoryNo != null)
            {
                condition += $" and factoryNo='{req.factoryNo}'";
            }
            if (req.meterType != null)
            {
                condition += $" and meterTypeNo='{req.meterType}'";
            }
            if (req.operatorName != null)
            {
                condition += $" and Operator='{req.operatorName}'";
            }
            var list = SqlHelper.Instance.GdcForCustomerInfo <CustomerView>("CustomerView", condition, dict);

            return(list.Count);
        }
Пример #16
0
        public async Task <ActionResult <CustomerWithSecRes> > Post([FromBody] CustomerReq request)
        {
            var response = await _customerService.CreateAsync(request);

            return(StatusCode(201, response));
        }
        public IActionResult DeleteCustomer([FromBody] CustomerReq req)
        {
            var res = _svc.DeleteCustomer(req.IdC);

            return(Ok(res));
        }
        public IActionResult UpdateAccount(String account, CustomerReq req)
        {
            var result = customerSvc.UpdateCustomer(account, req);

            return(Ok(result));
        }
Пример #19
0
 public object UpdateCustomer(String account, CustomerReq req)
 {
     return(customerRep.Update(account, req));
 }
Пример #20
0
        public IActionResult CreateCustomer([FromBody] CustomerReq req)
        {
            var result = _svc.CreateCustomer(req);

            return(Ok(result));
        }