public ActionResult UpdateClient(Client client) { if (ModelState.IsValid) { CompanyEntities4 db = new CompanyEntities4(); Client updateClient = (from c in db.Clients where c.Id_Client == client.Id_Client select c).FirstOrDefault(); //επέλεξε τον πελάτη απο την παράμετρο που θα σου δωθεί if (updateClient != null) { updateClient.FirstName = client.FirstName; updateClient.LastName = client.LastName; updateClient.Address = client.Address; updateClient.AFM = client.AFM; updateClient.Telephone = client.Telephone; updateClient.Brand_Name = client.Brand_Name; updateClient.DOY = client.DOY; } db.SaveChanges(); } return(new EmptyResult()); }
public ActionResult Registration([Bind(Exclude = "IsEmailVerified,ActivationCode")] Vendor vendor) { bool status = false; string message; // Mode Validation if (ModelState.IsValid) { #region Email already Exists var isExist = IsEmailExist(vendor.Email); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exists"); return(View(vendor)); } #endregion #region Generate Activation Code vendor.ActivationCode = Guid.NewGuid(); // περναει εναν κωδικό στο πεδιο του χρήστη #endregion #region Password Hashing vendor.Password = Crypto.Hash(vendor.Password); vendor.ConfirmPassword = Crypto.Hash(vendor.ConfirmPassword); #endregion vendor.IsEmailVerified = false; #region Save to Database using (CompanyEntities4 dc = new CompanyEntities4()) { dc.Vendors.Add(vendor); //παίρνει τις τιμες από τα texboxes dc.SaveChanges(); //και τα αποθηκευει στη βάση //Send Email to User SendVerificationLinkEmail(vendor.Email, vendor.ActivationCode.ToString()); message = "Registration successfully done. Account activation link" + "has been sent to your email id:" + vendor.Email; status = true; } #endregion } else { message = "Invalid Request"; } ViewBag.Message = message; ViewBag.Status = status; return(View(vendor)); }
public ActionResult InsertHistory(History history, string clientId) { if (ModelState.IsValid) { var db = new CompanyEntities4(); int.TryParse(clientId, out var id1); //cast σε int history.Id_Client = id1; // ->παιρνει το Id του client και το αποδιδει στη στήλη του orders για να τα αντιστοιχισει db.Histories.Add(history); db.SaveChanges(); //αποθήκευσε τις αλλαγές } return(new EmptyResult()); }
public ActionResult InsertClient(Client client) { var db = new CompanyEntities4(); var us = User.Identity.Name; //Παίρνουμε τα στοιχεία του τρέχων συνδεδεμένου χρήστη(Πώλητη) Vendor vendor = db.Vendors.FirstOrDefault(c => c.Email == us); // τσεκάρουμε εαν υπάρχει στη λίστα μας if (vendor != null) { client.VendorId = vendor.Id_Vendor; // ->παιρνει το Id του Vendor και το αποδιδει στη στήλη του client για να τα αντιστοιχισει db.Clients.Add(client); } db.SaveChanges(); //αποθήκευσε τις αλλαγές return(new EmptyResult()); }
public ActionResult DeleteClient(int clientId) { using (CompanyEntities4 db = new CompanyEntities4()) { Client client = (from c in db.Clients where c.Id_Client == clientId select c).FirstOrDefault(); if (client == null || clientId == 0) { return(new EmptyResult()); } db.Clients.Remove(client); db.SaveChanges(); } return(new EmptyResult()); }
public ActionResult DeleteOrders(int ordersId) { using (CompanyEntities4 db = new CompanyEntities4()) { Order order = (from o in db.Orders where o.Id == ordersId select o).FirstOrDefault(); if (order == null || ordersId == 0) { return(new EmptyResult()); } db.Orders.Remove(order); db.SaveChanges(); } return(new EmptyResult()); }
public ActionResult DeleteHistory(int historyId) { using (CompanyEntities4 db = new CompanyEntities4()) { History history = (from h in db.Histories where h.Id == historyId select h).FirstOrDefault(); if (history == null || historyId == 0) { return(new EmptyResult()); } db.Histories.Remove(history); db.SaveChanges(); } return(new EmptyResult()); }
public ActionResult VerifyAccount(string id) //αυτη η μέθοδος καλείται στη γραμμή 194 { bool status = false; using (CompanyEntities4 dc = new CompanyEntities4()) { dc.Configuration.ValidateOnSaveEnabled = false; //this line i have added here to avoid //confirm password does not match issue on save changes var v = dc.Vendors.FirstOrDefault(a => a.ActivationCode == new Guid(id)); if (v != null) { v.IsEmailVerified = true; dc.SaveChanges(); status = true; } else { ViewBag.Message = "Invalid Request"; } } ViewBag.Status = status; return(View()); }
public ActionResult UpdateHistory(History update) { if (ModelState.IsValid) { CompanyEntities4 db = new CompanyEntities4(); History updateHistory = (from c in db.Histories where c.Id == update.Id select c).FirstOrDefault(); //επέλεξε τον πελάτη απο την παράμετρο που θα σου δωθεί if (updateHistory != null) { updateHistory.Record = update.Record; updateHistory.Complaints = update.Complaints; updateHistory.Absence = update.Absence; updateHistory.Date = update.Date; updateHistory.Vendor_Name = update.Vendor_Name; } db.SaveChanges(); } return(new EmptyResult()); }
public ActionResult UpdateOrders(Order update) { if (ModelState.IsValid) { CompanyEntities4 db = new CompanyEntities4(); Order updateOrder = (from c in db.Orders where c.Id == update.Id select c).FirstOrDefault(); //επέλεξε τον πελάτη απο την παράμετρο που θα σου δωθεί if (updateOrder != null) { updateOrder.Date_order = update.Date_order; updateOrder.Medicine = update.Medicine; updateOrder.Quantity = update.Quantity; updateOrder.Vendor_Name = update.Vendor_Name; updateOrder.Unit_Price = update.Unit_Price; updateOrder.Order_Cost = update.Order_Cost; } db.SaveChanges(); } return(new EmptyResult()); }