public void Create([FromBody] CustomerVO customer) { if (ModelState.IsValid) { da.AddCustomer(Mapper.Map <Models.Customer>(customer)); } }
public OperationResult <int> AddCustomer(RequestOperation <CustomerLawyerData> request) { var result = new OperationResult <int>(); try { if (String.IsNullOrEmpty(request.Body.Name) && String.IsNullOrEmpty(request.Body.NickName)) { result.Message = "姓名不能为空"; return(result); } if (String.IsNullOrEmpty(request.Body.Name)) { request.Body.Name = request.Body.NickName; } if (String.IsNullOrEmpty(request.Body.NickName)) { request.Body.NickName = request.Body.Name; } var data = CustomerDA.AddCustomer(request); if (data == null || data.UserID <= 0) { result.ErrCode = 1; result.Message = "新增用户失败"; } else { result.ErrCode = 0; result.Message = "ok"; } } catch (Exception ex) { Logger.WriteException("AddCustomer", ex, request); result.ErrCode = -1; result.Message = ex.Message; } return(result); }
public HttpResponseMessage Post(Customer newCustomer) { try { if (newCustomer == null) { throw new HttpResponseException(AddRequest(HttpStatusCode.BadRequest, "parameter is empty")); } ClaimsPrincipal p = RequestContext.Principal as ClaimsPrincipal; int id = CustomerDA.AddCustomer(newCustomer, p.Claims); HttpResponseMessage response = new HttpResponseMessage(); string url = string.Format("{0}{1}", HttpContext.Current.Request.Url.ToString(), id); response.Headers.Location = new Uri(url); response.StatusCode = HttpStatusCode.Created; return(response); } catch { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
protected void btnEnter_Click(object sender, EventArgs e) { string firstName; string lastName; string email; string phone; int numberAppliance; int numRecords; firstName = txtFirstName.Text; lastName = txtLastName.Text; email = txtEmail.Text; phone = txtPhoneNumber.Text; numberAppliance = Convert.ToInt16(txtNumberAppliance.Text); // create the object Customer c = new Customer(firstName, lastName, email, phone, numberAppliance); Session["Cust"] = firstName; //do something with the object data lblMessage.Text = firstName + " " + lastName; //Add them to the database numRecords = CustomerDA.AddCustomer(c); if (numRecords > 0) { Server.Transfer("~/NewsLetter/ThankYou.aspx"); } else { Session["Cust"] = "Sorry add failed try later"; Server.Transfer("~/NewsLetter/ErrorPage.aspx"); } }
protected void btnSignUp_Click(object sender, EventArgs e) { string firstName = txtFirstName.Text; string lastName = txtLastName.Text; string address = txtAddress.Text; string city = txtCity.Text; string state = cmboState.SelectedValue; string zip = txtZip.Text; string phone = txtPhone.Text; string login = txtLogin.Text; string password = BCrypt.Net.BCrypt.HashPassword(txtPassword.Text, 10); Customer c = new Customer(); c.CustomerFirst = firstName; c.CustomerLast = lastName; c.CustomerAddress = address; c.CustomerCity = city; c.CustomerState = state; c.CustomerPhone = phone; c.CustomerLogin = login; c.CustomerPassword = password; ServiceZips zz = new ServiceZips(); zz.ServiceZip = txtZip.Text.ToString(); List <ServiceZips> zips = ServiceZipsDA.GetAllServiceZips(); foreach (ServiceZips z in zips) { if (zz.ServiceZip == z.ServiceZip) { c.CustomerZip = zz.ServiceZip; c.PrimaryStore = z.StoreNum; List <Customer> cc = CustomerDA.GetAllCustomers(); bool noDuplicates = false; foreach (Customer checker in cc) { if (checker.CustomerLogin == c.CustomerLogin) { lblError.Text = "That email is already taken, try another one or try logging in"; lblError.Visible = true; noDuplicates = false; break; } else { noDuplicates = true; } } if (noDuplicates) { Session["customer"] = c; CustomerDA.AddCustomer(c); //SmtpClient needs a host and port passed to it SmtpClient client = new SmtpClient(); //where you declare the host client.Host = "smtp.gmail.com"; //where you declare the port client.Port = 587; client.EnableSsl = true; client.DeliveryMethod = SmtpDeliveryMethod.Network; client.UseDefaultCredentials = false; client.Credentials = new NetworkCredential("*****@*****.**", "NotAnEasyPassword"); MailAddress from = new MailAddress("*****@*****.**"); MailAddress to = new MailAddress(login); MailMessage message = new MailMessage(from, to); message.Subject = "Your new account!"; message.Body = "Thank you for signing up for your new account " + firstName + "\nWe hope you enjoy the pizza!\n\nYour new account information,\n\n\tLogin:\t" + login + "\n\tPassword:\t" + password + "\n\tFirst Name:\t" + firstName + "\n\tLast Name:\t" + lastName + "\n\tAddress:\t" + address + "\n\tCity:\t" + city + "\n\tState:\t" + state + "\n\tPhone:\t" + phone; message.BodyEncoding = System.Text.Encoding.UTF8; //this is closed off for when there is no host or port, can't send mail unless it's online client.Send(message); Response.Redirect("~/"); } } } if (lblError.Text == "") { lblError.Text = "Something went wrong with creating your account, \nWe may be unable to deliver to you currently,\nContact us if you have questions."; lblError.Visible = true; } }