public string UpdateCustomerAccount(Customer _customer) { string updatedREsult = string.Empty; if (_customer != null) { using (ELFILOEntities _enties = new ELFILOEntities()) { var _cust = _enties.Customer.Where(x => x.accountNumber == _customer.accountNumber).FirstOrDefault(); _cust.customerType = _customer.customerType; _cust.firstName = _customer.firstName; _cust.lastName = _customer.lastName; _cust.terms = _customer.terms; _cust.address = _customer.address; _cust.contactNumber = _customer.contactNumber; if (_cust != null) { _enties.Customer.AddOrUpdate(_cust); } _enties.SaveChanges(); updatedREsult = "Successfully Updated"; } } else { updatedREsult = "Error While updating"; } return(updatedREsult); }
/// <summary> /// Create/Add New Customer /// </summary> /// <param name="_customer"></param> /// <returns></returns> public string AddCustomer(Customer _customer) { //check if its not null if (_customer != null) { using (ELFILOEntities _entiies = new ELFILOEntities()) { //add the passed object. Customer customer = new Customer(); customer.accountCode = _customer.accountCode; customer.accountNumber = _entiies.Database.SqlQuery <string>("EXEC GenerateCCAnumbers").FirstOrDefault(); customer.customerType = _customer.customerType; customer.terms = _customer.terms; customer.firstName = _customer.firstName; customer.lastName = _customer.lastName; customer.address = _customer.address; customer.contactNumber = _customer.contactNumber; customer.date_added = DateTime.Today; if (customer != null) { _entiies.Customer.Add(customer); } _entiies.SaveChanges(); //save data return("Customer Successfully Added"); } } else { return("Error While Inserting..."); } }
/// <summary> /// Add New Cagories /// </summary> /// <param name="category"></param> /// <returns></returns> public string AddItemCategory(Category category) { if (category != null) { using (ELFILOEntities _entities = new ELFILOEntities()) { _entities.Category.Add(category); _entities.SaveChanges(); return("Item Category Successfully Added"); } } else { return("Error while Inserting"); } }
/// <summary> /// Delette Customer Account /// </summary> /// <param name="_customer"></param> /// <returns></returns> public string DeleteCustomer(string accountNumber) { using (ELFILOEntities _entites = new ELFILOEntities()) { var result = _entites.Customer.Where(x => x.accountNumber == accountNumber).FirstOrDefault(); if (result != null) { _entites.Customer.Remove(result); _entites.SaveChanges(); return("Successfully Deleted"); } else { return("Unable to delete"); } } }
/// <summary> /// Add Item in Inventory /// </summary> /// <param name="inventory"></param> /// <returns></returns> public string AddIventoryItem(Models.Inventory inventory) { //check if its not null if (inventory != null) { using (ELFILOEntities _entiies = new ELFILOEntities()) { //add the passed object. _entiies.Inventory.Add(inventory); _entiies.SaveChanges(); return("Customer Successfully Added"); } } else { return("Error While Inserting"); } }
/// <summary> /// Account Transactions /// </summary> /// <param name="transaction"></param> /// <returns></returns> public string AddTransaction(Transaction transaction) { string _result = string.Empty; if (transaction != null) { using (ELFILOEntities _entities = new ELFILOEntities()) { _entities.Transaction.Add(transaction); _entities.SaveChanges(); _result = "Successfully Added"; } } else { _result = "Error Occured while adding"; } return(_result); }