//Ако върне тру значи служителя е премахнат успешно, за извикване от изглед public bool DeleteEmployee(string param) { using (var staffContext = new storage_managementEntities()) { int id; if (int.TryParse(param, out id) == true) { if (DeleteEmployeeById(id) == true) { return(true); } else { return(false); } } else { if (DeleteEmployeeByName(param) == true) { return(true); } else { return(false); } } } }
//Catch ArgumentNullException а случай, където може да има празно поле public bool Login(string username, string password) { if (username.Equals("") || password.Equals("")) { throw new ArgumentNullException(); } else { using (var staffContext = new storage_managementEntities()) { foreach (var employee in staffContext.staffs) { if (employee.username.Equals(username)) { if (employee.password.Equals(password)) { return(true); } } } staffContext.SaveChanges(); } return(false); } }
//Catch ArgumentNullException and FormatException за случай където може да има празни полета public bool Register(string first_name, string last_name, string email, string username, string password, int storage_id) { if (first_name.Equals("") || last_name.Equals("") || email.Equals("") || username.Equals("") || password.Equals("") || storage_id.Equals(0)) { throw new ArgumentNullException(); } else { using (var staffContext = new storage_managementEntities()) { staff emp = new staff(staffContext.staffs.Count(), first_name, last_name, email, username, password, storage_id); foreach (var employee in staffContext.staffs) { if (employee.email.Equals(email)) { return(false); } else if (employee.username.Equals(username)) { return(false); } } staffContext.staffs.Add(emp); staffContext.SaveChanges(); return(true); } } }
private item GetProductByName(string name) { using (var productContext = new storage_managementEntities()) { foreach (var product in productContext.items) { if (product.name.Equals(name)) { return(product); } } return(null); } }
private item GetProductById(int id) { using (var productContext = new storage_managementEntities()) { foreach (var product in productContext.items) { if (product.id_item.Equals(id)) { return(product); } } return(null); } }
private storage GetDepotByName(string Name) { using (var depotContext = new storage_managementEntities()) { foreach (var depot in depotContext.storages) { if (depot.name.Equals(Name)) { return(depot); } } return(null); } }
private storage GetDepotById(int id) { using (var depotContext = new storage_managementEntities()) { foreach (var depot in depotContext.storages) { if (depot.id_storage.Equals(id)) { return(depot); } } return(null); } }
//Връща фамилията на служителя public string GetEmployeeLastName(string username) { using (var staffContext = new storage_managementEntities()) { foreach (var employee in staffContext.staffs) { if (employee.username.Equals(username)) { return(employee.last_name); } } staffContext.SaveChanges(); return(null); } }
// Връща човек по зададено ид public staff GetEmployee(int id) { using (var staffContext = new storage_managementEntities()) { foreach (var employee in staffContext.staffs) { if (employee.id_staff.Equals(id)) { return(employee); } } staffContext.SaveChanges(); return(null); } }
private bool DeleteEmployeeById(int id) { using (var staffContext = new storage_managementEntities()) { foreach (var employee in staffContext.staffs) { if (employee.id_staff.Equals(id)) { staffContext.staffs.Remove(employee); staffContext.SaveChanges(); return(true); } } return(false); } }
//Вътрешни методи за извършване на триене на служител private bool DeleteEmployeeByName(string username) { using (var staffContext = new storage_managementEntities()) { foreach (var employee in staffContext.staffs) { if (employee.username.Equals(username)) { staffContext.staffs.Remove(employee); staffContext.SaveChanges(); return(true); } } return(false); } }
private bool DeleteProductByName(string name) { using (var productContext = new storage_managementEntities()) { foreach (var product in productContext.items) { if (product.name.Equals(name)) { productContext.items.Remove(product); productContext.SaveChanges(); return(true); } } return(false); } }
private bool DeleteProductById(int id) { using (var productContext = new storage_managementEntities()) { foreach (var product in productContext.items) { if (product.id_item.Equals(id)) { productContext.items.Remove(product); productContext.SaveChanges(); return(true); } } return(false); } }
private bool DeleteDepotByName(string Name) { using (var depotContext = new storage_managementEntities()) { foreach (var depot in depotContext.storages) { if (depot.name.Equals(Name)) { depotContext.storages.Remove(depot); depotContext.SaveChanges(); return(true); } } return(false); } }
private bool DeleteDepotById(int id) { using (var depotContext = new storage_managementEntities()) { foreach (var depot in depotContext.storages) { if (depot.id_storage.Equals(id)) { depotContext.storages.Remove(depot); depotContext.SaveChanges(); return(true); } } return(false); } }
//Ако върне тру значи е създадено ново депо, ако върне фалс значи такова депо съществува public bool CreateDepot(string name) { using (var depotContext = new storage_managementEntities()) { foreach (var depot in depotContext.storages) { if (depot.name.Equals(name)) { return(false); } } depotContext.storages.Add(new storage(name)); depotContext.SaveChanges(); return(true); } }
public bool CreateProduct(string name, string brand, double price, int quantity, bool isAvailable, int storageId) { using (var productContext = new storage_managementEntities()) { foreach (var product in productContext.items) { if (product.name.Equals(name)) { return(false); } } item item = new item(name, brand, price, quantity, isAvailable, storageId); productContext.items.Add(item); productContext.SaveChanges(); return(true); } }