// GET: Customer/Delete/5 public ActionResult Delete(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } customers customers = db.customers.Find(id); if (customers == null) { return(HttpNotFound()); } return(View(customers)); }
public CustomerViewModel getCustomer(customers customer) { if (customer == null) { return(null); } return(new CustomerViewModel { Id = customer.Id, Email = customer.email, FullName = customer.fullname, Address = customer.address, Phone = customer.phone, Occupation = customer.occupation }); }
public customers getCustomerByCustomerId(int customerId) { customers customer = new customers(); try { using (var ctx = new transshipEntities()) { ctx.Configuration.LazyLoadingEnabled = false; customer = ctx.customers.FirstOrDefault(x => x.customerId == customerId); return(customer); } } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
public customers SaveCustomer(customers model) { var customer = new customers(); try { using (var ctx = new transshipEntities()) { customer = ctx.customers.Add(model); ctx.SaveChanges(); return(customer); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
/// <summary> /// Permet d'ajouter un clients a la DB /// On appelle tout nos méthode de vérif si tout est ok on ajoute /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Button_AddCustomer_Click(object sender, RoutedEventArgs e) { if (Verif_Lastname() && Verif_Firstname() && Verif_Mail() && Verif_PhoneNumber() && Verif_Budget()) { customers addCustomer = new customers() { lastname = TextBox_Lastname.Text, firstname = TextBox_Firstname.Text, mail = TextBox_Mail.Text, phonenumber = TextBox_PhoneNumber.Text, budget = int.Parse(TextBox_Budget.Text) }; db.customers.Add(addCustomer); db.SaveChanges(); TextBlock_SuccesMessage.Text = "Ajout d'un client réussie"; } }
public customers UpdateCustomer(customers model) { customers customer = new customers(); customer = model; try { using (var ctx = new transshipEntities()) { ctx.Entry(customer).State = EntityState.Modified; ctx.SaveChanges(); return(customer); } }catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); throw e; } }
// POST: Delete //[HttpPost, ActionName("ListCustomers")] //[ValidateAntiForgeryToken] public ActionResult DeleteCustomerConfirm(int id) { // Methode pour supprimer un client qui a des rdv //if (id != null) { // List<appointements> list = db.appointements.Where(d => d.idCustomer == id).ToList(); // db.appointements.RemoveRange(list); // db.SaveChanges(); // db.customers.Remove(db.customers.Find(id)); // db.SaveChanges(); //} //return RedirectToAction("Index"); customers customerDel = db.customers.Find(id); db.customers.Remove(customerDel); db.SaveChanges(); return(View("SuccessDeleteCustomer")); }
public bool createCustomer(object[] newData) { int serviceNo = 9999; bool hasService = false; //prepare inputdata for ServiceContract creation object[] serviceInput = new object[3]; serviceInput[0] = newData[9]; serviceInput[1] = newData[13]; serviceInput[2] = newData[10]; serviceNo = createServiceContract(serviceInput); hasService = true; using (servicebaseEntities cc = new servicebaseEntities()) { try { customers c = new customers(); c.cname = newData[0].ToString(); c.street = newData[1].ToString(); c.city = newData[2].ToString(); c.postcode = (int)newData[3]; c.email = newData[4].ToString(); c.phone = newData[5].ToString(); c.panelcount = newData[6].ToString(); c.color = newData[7].ToString(); c.inverter = newData[8].ToString(); c.paneltype = (String)newData[14]; c.serviceno = serviceNo; c.hasservice = hasService; cc.customers.Add(c); } catch { } cc.SaveChanges(); } return true; }
public ActionResult CustomerDetails(customers customer) { using (var dc = new MySQLEntities()) { if (customer.idcustomers == Guid.Empty) { customer.idcustomers = Guid.NewGuid(); dc.customers.Add(customer); dc.SaveChanges(); } else { dc.Entry(customer).State = EntityState.Modified; dc.SaveChanges(); } } return(RedirectToAction("Customers")); }
public customers CreateCustomer(string CustomerName, string Country, string Currency, int Budget, int TimeBudget, string Number = "", string Comment = "", string Company = "", string Contact = "", string Address = "", string Phone = "", string Email = "") { customers customer = new customers() { name = CustomerName, country = Country, currency = Currency, budget = Budget, time_budget = TimeBudget, number = Number, comment = Comment, company = Company, contact = Contact, address = Address, phone = Phone, email = Email }; return(customer); }
public ActionResult EditCustomer([Bind(Include = "idCustomers,lastname,firstname,mail,phoneNumber,budget")] customers customer) { if (ModelState.IsValid) { if (customer.budget == null) { customer.budget = 0; } db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); TempData["messageEditCustomer"] = "Client modifié"; /*TempData["errorForm"] = 0;*/ /*return RedirectToAction("ProfilCustomer/" + customer.idCustomers);*/ return(Json(new { success = true, response = "/Customers/ProfilCustomer/" + customer.idCustomers })); } /*TempData["defaultBudget"] = customer.budget;*/ /*TempData["errorForm"] = 1;*/ /*return View("ProfilCustomer", customer);*/ /*return PartialView(customer);*/ return(Json(new { success = false, errors = ModelState.Values.SelectMany(x => x.Errors).Select(x => x.ErrorMessage).ToList() })); }
public ActionResult Register(customers cust) { try { customers cs = new customers(); cs.FirstName = cust.FirstName; cs.LastName = cust.LastName; cs.Gender = cust.Gender; cs.Email = cust.Email; cs.Mobile = cust.Mobile; cs.UPass = cust.UPass; cs.IsVerified = "No"; db.customers.Add(cs); db.SaveChanges(); } catch (Exception exe) { throw exe; } return(RedirectToAction("Index", "Home")); }
public ActionResult AddUserProfilePartialView(customers item) { customers.Insertcustomers(item); return(RedirectToAction("AddServicesProfile", new { id = item.Uid })); }
public HttpResponseMessage UploadLogo() { var filePath = "~/Logos/"; customers customer = new customers(); customers customers; BOUsers user = new BOUsers(); var logo = HttpContext.Current.Request.Files.AllKeys.Any(); //get paramaetes shipment files var customerId = HttpContext.Current.Request.Params["model.customerId"]; try { if (HttpContext.Current.Request.Files.AllKeys.Any()) { // Get the uploaded image from the Files collection var httpPostedFile = HttpContext.Current.Request.Files["UploadLogo"]; if (httpPostedFile != null) { var file_name = httpPostedFile.FileName; // Get the complete file path string fileSave = DateTime.Now.ToString("yyyyMMddHHmmss") + file_name; // if the directory doesn't exist - create it. if (!Directory.Exists(HttpContext.Current.Server.MapPath(filePath + "/" + customerId))) { Directory.CreateDirectory(HttpContext.Current.Server.MapPath(filePath + "/" + customerId)); string path = filePath + "/" + customerId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } else { string path = filePath + "/" + customerId + "/" + fileSave; httpPostedFile.SaveAs(HttpContext.Current.Server.MapPath(path)); } customer.logo = fileSave; } //map de parametes to model shipment attachment customer.customerId = Convert.ToDecimal(customerId); } BOCustomers custom = new BOCustomers(); customer.customerId = Convert.ToDecimal(customerId); customers = custom.GetCustomerByCustomerId(Convert.ToInt32(customerId)); customers.logo = customer.logo; customers = user.updateProfile(customers); return(Request.CreateResponse(HttpStatusCode.OK, customers)); } catch (Exception e) { ErrorMessage mensaje = new ErrorMessage("2.1", "Exception to update Profile - " + e.GetBaseException().Message, e.ToString()); return(Request.CreateResponse(HttpStatusCode.InternalServerError, mensaje)); } }
public void AddCustomer(customers customer) { customers.Add(customer); }
public customers SaveCustomer(customers model) { return(customer.SaveCustomer(model)); }
/// <summary> /// /// </summary> /// <param name="customer"></param> public void save(customers customer) { entity.customers.Add(customer); entity.SaveChanges(); }
public ActionResult Regiters(customers Member) { dbo.save(Member); return(RedirectToAction("Login")); }
public decimal CreateUser(CreateUserObject createUserObject, string baseURI) { var stopwatch = new Stopwatch(); stopwatch.Start(); var returnValue = (decimal)0; var passwd = string.Empty; using (var dbTran = _transshipEntities.Database.BeginTransaction()) { try { var newCustomer = new customers { company_name = createUserObject.companyname, countryId = createUserObject.idCountry, city = createUserObject.city, estimated_membership = createUserObject.membership, address1 = createUserObject.addr1, address2 = createUserObject.addr2, zipcode = createUserObject.zipcode, status = "P", register_date = DateTime.Today, state = createUserObject.usstate }; _transshipEntities.customers.Add(newCustomer); passwd = TransShip.Security.Security.Encrypt(DateTime.Now.ToString(), new RijndaelManaged(), TransShip.Security.Security.GenerateKey(new RijndaelManaged(), 256)); var newUser = new users { customerId = newCustomer.customerId, full_name = createUserObject.fullname, email = createUserObject.email, password = TransShip.Security.Security.Encrypt(createUserObject.keyinformation, new RijndaelManaged(), KEY), user_type = "C", status = "I", role = "A", confirmationKey = passwd }; _transshipEntities.users.Add(newUser); var newContact = new customer_contacts { customerId = newCustomer.customerId, full_name = createUserObject.fullname, title = createUserObject.title, phone_number = createUserObject.phonenumber, email = createUserObject.email }; _transshipEntities.customer_contacts.Add(newContact); _transshipEntities.SaveChanges(); returnValue = newUser.userId; dbTran.Commit(); } catch (Exception e) { LogBook.TextLog.Info(string.Format("{0} {1}", e.Message, e.InnerException != null ? e.InnerException.Message : string.Empty)); } finally { stopwatch.Stop(); LogBook.TextLog.Info(string.Format("Ellapsed time {0} milli seconds", stopwatch.ElapsedMilliseconds)); var emailhandler = new TransShip.EMailHandler.EMailHandler(); emailhandler.SendConfirmationEmail(string.Format("your registration has been successful, TranShip will contact you "), string.Format("{0}?apiInformation={1}", baseURI, HttpUtility.UrlEncode(passwd)), createUserObject.email); } } return(returnValue); }
private void Update_Click(object sender, RoutedEventArgs e) { string mailRegex = @"^[\w\.=-]+@[\w\.-]+\.[\w]{2,3}$"; string phoneNumberRegex = @"^0[0-9]{9}$"; string LastnameRegex = @"^[A-Za-zéàèêëïîç\- ]+$"; bool isValid = true; int idCustomer = int.Parse(TextBoxIdCustomer.Text); TextBlockErrorPhoneNumber.Text = ""; TextBlockErrorLastname.Text = ""; TextBlockErrorFirstname.Text = ""; TextBlockErrorMail.Text = ""; TextBlockErrorBudget.Text = ""; // si les champs sont corrects continuer la vérification, sinon faire apparaitre un message d'erreur if (!string.IsNullOrEmpty(TextBoxLastName.Text) && !string.IsNullOrEmpty(TextBoxFirstName.Text) && !string.IsNullOrEmpty(TextBoxEmail.Text) && !string.IsNullOrEmpty(TextBoxPhoneNumber.Text) && !string.IsNullOrEmpty(TextBoxBudgetGold.Text)) { // vérifie la Regex avec le champs textboslastname et la variable apeller lastnameregex if (!Regex.IsMatch(TextBoxLastName.Text, LastnameRegex)) { TextBlockErrorLastname.Text = "Erreur le nom est incorrect"; isValid = false; // Confirme que la condition est fausse par la propriété bool et affiche un message d'erreur } if (!Regex.IsMatch(TextBoxFirstName.Text, LastnameRegex)) { TextBlockErrorFirstname.Text = "Erreur le prénom est incorrect"; isValid = false; } if (!Regex.IsMatch(TextBoxEmail.Text, mailRegex)) { TextBlockErrorMail.Text = "Erreur le mail est incorrect"; isValid = false; } else if (db.customers.Any(x => x.mail == TextBoxEmail.Text & x.idCustomers != idCustomer)) { TextBlockErrorMail.Text = "Cette adresse mail existe déjà"; isValid = false; } if (!Regex.IsMatch(TextBoxPhoneNumber.Text, phoneNumberRegex)) { TextBlockErrorPhoneNumber.Text = "Erreur le numéro est incorrect"; isValid = false; } if (!int.TryParse(TextBoxBudgetGold.Text, out int budgetGold) || budgetGold < 0) { TextBlockErrorBudget.Text = "Erreur le budget est incorrect"; isValid = false; } if (isValid) { try { customers customerToUpdate = new customers() // declaration de l'objet customerToUpdate et l'instancie avec la class customers (récupére tous les attributs appointments. { lastname = TextBoxLastName.Text, // J'attribue la valeur à l'attribut lastname de l'objet customerToUpdate firstname = TextBoxFirstName.Text, mail = TextBoxEmail.Text, phonenumber = TextBoxPhoneNumber.Text, budget = budgetGold }; db.SaveChanges(); //Enregistre //Message de mofifications et d'erreurs MessageBox.Show("Le client a bien été modifié.", "Client modifié", MessageBoxButton.OK); } catch { MessageBox.Show("Une erreur s'est produite, veuillez réessayer.", "Erreur", MessageBoxButton.OK, MessageBoxImage.Error); // Si il y a une erreur pendant l'enregistrement affiche un message d'erreur } } } }
public customers UpdateCustomer(customers model) { return(customer.UpdateCustomer(model)); }
public customers updateProfile(customers model) { return(user.UpdateProfile(model)); }
public customer(customers c) { id = c.id; email = c.email; }
[ActionName("AddCustomer")] // Nom de la méthode à utiliser public ActionResult AddCustomerPost() { customers customerToAdd = new customers(); TryUpdateModel(customerToAdd); //vérification que le champ lastname n'est pas null ou vide if (!String.IsNullOrEmpty(customerToAdd.lastname)) { // Vérif de la validité de l'entrée if (!Regex.IsMatch(customerToAdd.lastname, regexName)) // (valeur qu'on test, pattern) ! : si ça passe pas --> message erreur { ModelState.AddModelError("lastname", "Ecrire un nom valide"); // on ajoute erreur sur lastname et message d'erreur } } else { ModelState.AddModelError("lastname", "Ecrire un nom"); } // vérification que le champ firstname n'est pas null ou vide if (!String.IsNullOrEmpty(customerToAdd.firstname)) { // Vérif de la validité de l'entrée if (!Regex.IsMatch(customerToAdd.firstname, regexName)) { ModelState.AddModelError("firstname", "Ecrire un prénom valide"); } } else { ModelState.AddModelError("firstname", "Ecrire un prénom"); } // Vérification que le champs mail n'est pas null, vide ou identique au mail d'un autre client if (!String.IsNullOrEmpty(customerToAdd.mail)) { // Vérification de la validité de l'entrée var isAlreadyUsed = db.customers.Where(cus => cus.mail == customerToAdd.mail).SingleOrDefault(); // valeur null par defaut if (!Regex.IsMatch(customerToAdd.mail, regexMail)) { // Message d'erreur ModelState.AddModelError("mail", "Ecrire un mail valide"); } // Vérifie si ce mail est déjà utilisé else if (isAlreadyUsed != null) { ModelState.AddModelError("mail", "Un client existant porte cette adresse mail"); } } else { // Message d'erreur ModelState.AddModelError("mail", "Ecrire un email"); } // vérification que le champ phoneNumber n'est pas null ou vide if (!String.IsNullOrEmpty(customerToAdd.phoneNumber)) { // Vérif de la validité de l'entrée if (!Regex.IsMatch(customerToAdd.phoneNumber, regexPhone)) { ModelState.AddModelError("phoneNumber", "Ecrire un numéro de téléphone valide"); } } else { ModelState.AddModelError("phoneNumber", "Ecrire un numéro de téléphone"); } // vérification du champ budget if (customerToAdd.budget <= 0) { ModelState.AddModelError("budget", "budget non valide"); } // vérification pour le champ subject if (!String.IsNullOrEmpty(customerToAdd.subject)) { // Vérif de la validité de l'entrée if (!Regex.IsMatch(customerToAdd.subject, regexSubject)) { ModelState.AddModelError("subject", "Ecrire un sujet valide"); } } else { ModelState.AddModelError("subject", "Ecrire un sujet"); } if (ModelState.IsValid) { db.customers.Add(customerToAdd); // insertion dans la bdd avec .Add db.SaveChanges(); // enregistrer les changements return(RedirectToAction("SuccessAddCustomer")); // rediriger vers une page de succès } else { return(View(customerToAdd)); //réaffichage du formulaire } }
private void metroTile4_Click(object sender, EventArgs e) { customers c = new customers(); c.Show(); }