Пример #1
0
        // POST api/<controller>
        public IHttpActionResult Register(CustomerRegisterDTO customerRegisterDTO)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest("請檢查欄位是否有遺漏"));
            }
            if (customerService.AccountIsduplicate(customerRegisterDTO.C_Account))
            {
                return(BadRequest("帳號已被註冊!"));
            }
            if (customerService.PhoneNumIsDuplicate(customerRegisterDTO.C_PhoneNum))
            {
                return(BadRequest("手機號碼已經使用過囉"));
            }

            var customer = Mapper.Map <CustomerRegisterDTO, Customer>(customerRegisterDTO);
            var result   = customerService.Register(ref customer);

            if (result.Success == false)
            {
                return(BadRequest("Error 資料有誤"));
            }

            return(Created(new Uri(Request.RequestUri + "/" + customer.C_Id), customer));
        }