/// <summary> /// Retrieve Company data using unique ID /// </summary> /// <param name="_Id"></param> /// <returns>Company Object</returns> public Company Get(Int32 _Id) { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.Get(_Id)); } }
public WorkerController() { string connectionString = ConfigurationManager.ConnectionStrings["GetConnection"].ConnectionString; workerAccess = new WorkerDataAccess(connectionString); companyAccess = new CompanyDataAccess(connectionString); }
/// <summary> /// Retrieve list of Company by query String. /// <param name="query"></param> /// </summary> /// <returns>List of Company</returns> public CompanyList GetByQuery(String query) { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.GetByQuery(query)); } }
public ActionResult EditDataCompany(CompanyViewModel paramEditCompany) { if (ModelState.IsValid) { //update data manual createby and createdate paramEditCompany.updateBy = "Tian"; paramEditCompany.updateDate = DateTime.Now; int?nameV = CompanyDataAccess.NameValidation(paramEditCompany.name); if (nameV <= 1) { if (CompanyDataAccess.UpdateCompany(paramEditCompany)) { return(Json(new { success = true, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Company name " + paramEditCompany.name + " is exist !" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Wajib menginputkan semua kotak bertanda bintang" }, JsonRequestBehavior.AllowGet)); } }
/// <summary> /// Retrieves Get Total Rows of Company /// </summary> /// <returns>Int32 type object</returns> public Int32 GetRowCount() { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.GetRowCount()); } }
/// <summary> /// Retrieve list of Company. /// no parameters required to be passed in. /// </summary> /// <returns>List of Company</returns> public CompanyList GetAll() { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.GetAll()); } }
/// <summary> /// Retrieve list of Company by PageRequest. /// <param name="request"></param> /// </summary> /// <returns>List of Company</returns> public CompanyList GetPaged(PagedRequest request) { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.GetPaged(request)); } }
public void TestLoadAllCompanies() { var c1 = new Company { Name = "Company1", Id = 1}; var c2 = new Company { Name = "Company2", Id = 2}; var c3 = new Company { Name = "Company3", Id = 3}; var c4 = new Company { Name = "Company4", Id = 4}; var mock = new Mock<IRepository<Company>>(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetAll()).Returns(new List<Company> { c1, c2, c3, c4 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); List<Company> companies = companyDataAccess.LoadAllCompanies(); Assert.IsNotNull(companies); companyDataAccess.SaveCompany(c1); companyDataAccess.SaveCompany(c2); companyDataAccess.SaveCompany(c3); companyDataAccess.SaveCompany(c4); companies = companyDataAccess.LoadAllCompanies(); Assert.IsNotNull(companies); Assert.AreEqual(4, companies.Count); }
/// <summary> /// Delete operation for Company /// <param name="_Id"></param> /// <returns></returns> private bool Delete(Int32 _Id) { using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { // return if code > 0 return(data.Delete(_Id) > 0); } }
public void TestLoadNotExistingCompany2() { var mock = new Mock <IRepository <Company> >(); var companyDataAccess = new CompanyDataAccess(mock.Object); Company loadedCompany = companyDataAccess.LoadCompany(-1); Assert.IsNull(loadedCompany); }
protected void EmployeeIDDropDownList_SelectedIndexChanged(object sender, EventArgs e) { CompanyDetailsModel companymodel = new CompanyDetailsModel(); CompanyDataAccess companyaccess = new CompanyDataAccess(); companymodel = companyaccess.GetCompanyDetails(Convert.ToInt32(EmployeeIDDropDownList.SelectedValue)); Employer_NameTextBox.Text = companymodel.Employer_Name; Contact_NumberTextBox.Text = companymodel.Contact_Number; LocationTextBox.Text = companymodel.Location; WebsiteTextBox.Text = companymodel.Website; }
public JsonResult DeleteDataCompany(int paramId) { string latestCode = CompanyDataAccess.DeleteCompany(paramId); if (latestCode != "") { return(Json(new { success = true, latestCode, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } }
public void TestSaveMultipleCompanies() { var c1 = new Company { Name = "Company1", Id = 1 }; var c2 = new Company { Name = "Company2", Id = 2 }; var c3 = new Company { Name = "Company3", Id = 3 }; var c4 = new Company { Name = "Company4", Id = 4 }; var mock = new Mock <IRepository <Company> >(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetQuery()).Returns(new List <Company> { c1, c2, c3, c4 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(c1); companyDataAccess.SaveCompany(c2); companyDataAccess.SaveCompany(c3); companyDataAccess.SaveCompany(c4); Company loadedCompany = companyDataAccess.LoadCompany(c1.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c1.Id); Assert.AreEqual(loadedCompany.Name, c1.Name); loadedCompany = companyDataAccess.LoadCompany(c2.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c2.Id); Assert.AreEqual(loadedCompany.Name, c2.Name); loadedCompany = companyDataAccess.LoadCompany(c3.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c3.Id); Assert.AreEqual(loadedCompany.Name, c3.Name); loadedCompany = companyDataAccess.LoadCompany(c4.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c4.Id); Assert.AreEqual(loadedCompany.Name, c4.Name); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { CompanyDataAccess obj = new CompanyDataAccess(); List <int> EmpIDList = obj.GetEmployeeID(); int i = 0; foreach (int EmpID in EmpIDList) { EmployeeIDDropDownList.Items.Insert(i, new ListItem(EmpID.ToString())); i++; } } UnobtrusiveValidationMode = UnobtrusiveValidationMode.None; }
public MainViewModel() { var personData = new PersonDataAccess(RepositoryFactory <Person> .GetRepository()); var companyData = new CompanyDataAccess(RepositoryFactory <Company> .GetRepository()); var invoiceData = new InvoiceDataAccess(RepositoryFactory <Invoice> .GetRepository(), RepositoryFactory <InvoiceRow> .GetRepository()); var userData = new UserDataAccess(RepositoryFactory <User> .GetRepository()); RegistratePersonViewModel = new RegistratePersonViewModel(personData); RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData); RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData); InvoiceViewModel = new InvoiceViewModel(invoiceData); userData.AddUser("admin", "admin"); LoginViewModel = new LoginViewModel(userData); }
public MainViewModel() { var personData = new PersonDataAccess(RepositoryFactory<Person>.GetRepository()); var companyData = new CompanyDataAccess(RepositoryFactory<Company>.GetRepository()); var invoiceData = new InvoiceDataAccess(RepositoryFactory<Invoice>.GetRepository(), RepositoryFactory<InvoiceRow>.GetRepository()); var userData = new UserDataAccess(RepositoryFactory<User>.GetRepository()); RegistratePersonViewModel = new RegistratePersonViewModel(personData); RegistrateCompanyViewModel = new RegistrateCompanyViewModel(companyData); RegisterInvoiceViewModel = new RegistrateInvoiceViewModel(invoiceData, companyData, personData); InvoiceViewModel = new InvoiceViewModel(invoiceData); userData.AddUser("admin", "admin"); LoginViewModel = new LoginViewModel(userData); }
/// <summary> /// Retrieve list of Company. /// </summary> /// <param name="fillChild"></param> /// <returns>List of Company</returns> public CompanyList GetAll(bool fillChild) { CompanyList companyList = new CompanyList(); using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { companyList = data.GetAll(); } if (fillChild) { foreach (Company companyObject in companyList) { FillCompanyWithChilds(companyObject, fillChild); } } return(companyList); }
public void TestSaveOneCompany() { var company = new Company {Name = "Company1", Id = 1}; var mock = new Mock<IRepository<Company>>(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetQuery()).Returns(new List<Company> {company}.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(company); Company loadedCompany = companyDataAccess.LoadCompany(company.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, company.Id); Assert.AreEqual(loadedCompany.Name, company.Name); }
/// <summary> /// Insert new company. /// data manipulation for insertion of Company /// </summary> /// <param name="companyObject"></param> /// <returns></returns> private bool Insert(Company companyObject) { // new company using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { // insert to companyObject Int32 _Id = data.Insert(companyObject); // if successful, process if (_Id > 0) { companyObject.Id = _Id; return(true); } else { return(false); } } }
/// <summary> /// Update base of Company Object. /// Data manipulation processing for: new, deleted, updated Company /// </summary> /// <param name="companyObject"></param> /// <returns></returns> public bool UpdateBase(Company companyObject) { // use of switch for different types of DML switch (companyObject.RowState) { // insert new rows case BaseBusinessEntity.RowStateEnum.NewRow: return(Insert(companyObject)); // delete rows case BaseBusinessEntity.RowStateEnum.DeletedRow: return(Delete(companyObject.Id)); } // update rows using (CompanyDataAccess data = new CompanyDataAccess(ClientContext)) { return(data.Update(companyObject) > 0); } }
private void button9_Click(object sender, EventArgs e) { try { CompanyDetailsModel com = new CompanyDetailsModel() { Employer_Name = Employertextbox.Text, Contact_Number = Convert.ToInt64(ContactNumbertextbox.Text), Location = Locationtextbox.Text, Website = Websitetextbox.Text, }; CompanyDataAccess company = new CompanyDataAccess(); company.SaveCompany(com); } catch (Exception ex) { MessageBox.Show("Please enter the values:"); } }
public void TestLoadNotExistingCompany() { var c1 = new Company { Name = "Company1", Id = 1 }; var mock = new Mock <IRepository <Company> >(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetAll()).Returns(new List <Company> { c1 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(c1); Company loadedCompany = companyDataAccess.LoadCompany(-1); Assert.IsNull(loadedCompany); }
protected virtual void Dispose(bool disposing) { if (this.disposed) { return; } if (disposing) { if (this.instance != null) { this.instance.Dispose(); this.instance = null; } ////Clean all memeber and release resource. } // Free any unmanaged objects here. disposed = true; }
public ActionResult CreateDataCompany(CompanyViewModel paramAddCompany) { if (ModelState.IsValid) { //is delete default value paramAddCompany.isDelete = false; //update data manual createby and createdate paramAddCompany.createBy = "Anastasia"; paramAddCompany.createDate = DateTime.Now; int?nameV = CompanyDataAccess.NameValidation(paramAddCompany.name); if (nameV == 0) { string latestCode = CompanyDataAccess.CreateCompany(paramAddCompany); if (latestCode != "") { return(Json(new { success = true, latestCode, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } else { return(Json(new { success = false, message = CompanyDataAccess.Message }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Company name " + paramAddCompany.name + " is exist !" }, JsonRequestBehavior.AllowGet)); } } else { return(Json(new { success = false, message = "Wajib menginputkan semua kotak bertanda bintang" }, JsonRequestBehavior.AllowGet)); //return PartialView("Add", paramAddCompany); } }
public void TestLoadAllCompanies() { var c1 = new Company { Name = "Company1", Id = 1 }; var c2 = new Company { Name = "Company2", Id = 2 }; var c3 = new Company { Name = "Company3", Id = 3 }; var c4 = new Company { Name = "Company4", Id = 4 }; var mock = new Mock <IRepository <Company> >(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetAll()).Returns(new List <Company> { c1, c2, c3, c4 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); List <Company> companies = companyDataAccess.LoadAllCompanies(); Assert.IsNotNull(companies); companyDataAccess.SaveCompany(c1); companyDataAccess.SaveCompany(c2); companyDataAccess.SaveCompany(c3); companyDataAccess.SaveCompany(c4); companies = companyDataAccess.LoadAllCompanies(); Assert.IsNotNull(companies); Assert.AreEqual(4, companies.Count); }
public void TestSaveMultipleCompanies() { var c1 = new Company { Name = "Company1", Id = 1}; var c2 = new Company { Name = "Company2", Id = 2}; var c3 = new Company { Name = "Company3", Id = 3}; var c4 = new Company { Name = "Company4", Id = 4}; var mock = new Mock<IRepository<Company>>(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetQuery()).Returns(new List<Company> { c1, c2, c3, c4 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(c1); companyDataAccess.SaveCompany(c2); companyDataAccess.SaveCompany(c3); companyDataAccess.SaveCompany(c4); Company loadedCompany = companyDataAccess.LoadCompany(c1.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c1.Id); Assert.AreEqual(loadedCompany.Name, c1.Name); loadedCompany = companyDataAccess.LoadCompany(c2.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c2.Id); Assert.AreEqual(loadedCompany.Name, c2.Name); loadedCompany = companyDataAccess.LoadCompany(c3.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c3.Id); Assert.AreEqual(loadedCompany.Name, c3.Name); loadedCompany = companyDataAccess.LoadCompany(c4.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, c4.Id); Assert.AreEqual(loadedCompany.Name, c4.Name); }
public void TestSaveOneCompany() { var company = new Company { Name = "Company1", Id = 1 }; var mock = new Mock <IRepository <Company> >(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetQuery()).Returns(new List <Company> { company }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(company); Company loadedCompany = companyDataAccess.LoadCompany(company.Id); Assert.IsNotNull(loadedCompany); Assert.AreEqual(loadedCompany.Id, company.Id); Assert.AreEqual(loadedCompany.Name, company.Name); }
protected void CompanyDetailsSave_Click(object sender, EventArgs e) { try { CompanyDetailsModel companymodel = new CompanyDetailsModel() { Employer_Name = Employer_NameTextBox.Text, Contact_Number = Contact_NumberTextBox.Text, Location = LocationTextBox.Text, Website = WebsiteTextBox.Text, }; CompanyDataAccess companydata = new CompanyDataAccess(); string cmpdata = companydata.SaveCompany(companymodel); if (cmpdata.Equals("success")) { Response.Write("<script>alert('Details have been saved successfully!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Please enter the values!" + ex.Message + "');</script>"); } }
protected void CompanyDetailsEdit_Click(object sender, EventArgs e) { try { CompanyDetailsModel model = new CompanyDetailsModel() { Employer_Name = Employer_NameTextBox.Text, EmployeeID = Convert.ToInt32(EmployeeIDDropDownList.SelectedValue), Contact_Number = Contact_NumberTextBox.Text, Location = LocationTextBox.Text, Website = WebsiteTextBox.Text, }; CompanyDataAccess access = new CompanyDataAccess(); string cmpaccess = access.EditCompany(model); if (cmpaccess.Equals("success")) { Response.Write("<script>alert('Details have been updated successfully!');</script>"); } } catch (Exception ex) { Response.Write("<script>alert('Please enter the values!" + ex.Message + "');</script>"); } }
public CompanyController() { var bucket = ClusterHelper.GetBucket(ConfigurationManager.AppSettings["CouchbaseBucket"]); _dataAccess = new CompanyDataAccess(bucket); }
public CompanyController(BepwayContext context, IMapper mapper) { Context = context; Mapper = mapper; dataAccess = new CompanyDataAccess(Context); }
public CompanyRepository(long userid) { this.UserId = userid; this.instance = new CompanyDataAccess(); }
public MainPageViewModel() { CompanyDataAccess cda = new CompanyDataAccess(RepositoryFactory<Company>.GetRepository()); Companys = new ObservableCollection<Company>(cda.LoadAllCompanies()); }
public MainPageViewModel() { CompanyDataAccess cda = new CompanyDataAccess(RepositoryFactory <Company> .GetRepository()); Companys = new ObservableCollection <Company>(cda.LoadAllCompanies()); }
public void TestLoadNotExistingCompany() { var c1 = new Company { Name = "Company1", Id = 1}; var mock = new Mock<IRepository<Company>>(); mock.Setup(repo => repo.SaveChanges()); mock.Setup(repo => repo.GetAll()).Returns(new List<Company> { c1 }.AsQueryable); var companyDataAccess = new CompanyDataAccess(mock.Object); companyDataAccess.SaveCompany(c1); Company loadedCompany = companyDataAccess.LoadCompany(-1); Assert.IsNull(loadedCompany); }
public void TestLoadNotExistingCompany2() { var mock = new Mock<IRepository<Company>>(); var companyDataAccess = new CompanyDataAccess(mock.Object); Company loadedCompany = companyDataAccess.LoadCompany(-1); Assert.IsNull(loadedCompany); }
public CompanyBusiness() { _companyDataAccess = new CompanyDataAccess(); }