public Jsend <List <ValidationFailure> > InsertUpdateCompany(CompanyModel data) { if (data == null) { return(JsendResult <List <ValidationFailure> > .Error("Company data can't be null")); } var validator = new CompanyValidator(); ValidationResult validateResult = validator.Validate(data); if (validateResult.IsValid) { try { var result = _uow.CompanyTRepository.FindByID(data.CompanyID); if (result == null) { _uow.CompanyTRepository.Add( new CompanyT { CompanyName = data.CompanyName, CompanyCode = data.CompanyCode, TaxID = data.TaxID, Phone = data.Phone, Owner = data.Owner, WebsiteURL = data.WebsiteURL, Address = data.Address }); } else { _uow.CompanyTRepository.Update( new CompanyT { CompanyID = data.CompanyID, CompanyName = data.CompanyName, CompanyCode = data.CompanyCode, TaxID = data.TaxID, Phone = data.Phone, Owner = data.Owner, WebsiteURL = data.WebsiteURL, Address = data.Address }); } _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <List <ValidationFailure> > .Error("Queay data occured error")); } return(JsendResult <List <ValidationFailure> > .Success()); } List <ValidationFailure> failures = validateResult.Errors.ToList(); return(JsendResult <List <ValidationFailure> > .Fail(failures)); }
public ActionResult RemoveRoleFromUser(int userId, int roleId) { try { _userManager.RemoveRoleFromUser(userId, roleId); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("RemoveRoleFromUser occured error"))); }
public ActionResult FindComapnyByName(string name) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <CompanyModel> > >( $"{apiDomain}/api/Company/FindComapnyByName?name={name}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得公司發生錯誤"))); } }
public Jsend <List <ValidationFailure> > InsertUpdateProduct(ProductModel data) { if (data == null) { return(JsendResult <List <ValidationFailure> > .Error("Product data can't be null")); } var validator = new ProductValidator(); ValidationResult validateResult = validator.Validate(data); if (validateResult.IsValid) { try { var result = _uow.ProductTRepository.FindByID(data.ProductID); if (result == null) { _uow.ProductTRepository.Add(new ProductT { ProductID = data.ProductID, ProductName = data.ProductName, ProductType = data.ProductType, Price = data.Price, Unit = data.Unit }); } else { _uow.ProductTRepository.Update(new ProductT { ProductID = data.ProductID, ProductName = data.ProductName, ProductType = data.ProductType, Price = data.Price, Unit = data.Unit }); } _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <List <ValidationFailure> > .Error("InsertUpdateProduct() InsertUpdate data occured error")); } return(JsendResult <List <ValidationFailure> > .Success()); } List <ValidationFailure> failures = validateResult.Errors.ToList(); return(JsendResult <List <ValidationFailure> > .Fail(failures)); }
public ActionResult GetCompanyByName(string name) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <CompanyModel> >( $"{apiDomain}/api/Company/GetCompanyByName?name={name}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("GetCompanyList occured error"))); } }
public ActionResult GetListByCompanyID(int id, int currentPage, bool isDesc) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <EmployeeModel, CompanyModel> > >( $"{apiDomain}/api/Employee/GetListByCompanyID?id={id}¤tPage={currentPage}&itemsPerPage=10&isDesc={isDesc}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得員工發生錯誤"))); } }
public ActionResult GetCompanyByID(string id) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <CompanyModel> > >( $"{apiDomain}/api/Company?id={id}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("GetCompanyList occured error"))); } }
public ActionResult GetEmployeeByID(string id) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <EmployeeModel> > >( $"{apiDomain}/api/Employee/?id={id}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得員工發生錯誤"))); } }
public ActionResult FindAllByEmployeeBirthday(string companyID, string searchText, int currentPage, int itemsPerPage, bool isDesc = false) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <EmployeeModel, CompanyModel> > >( $"{apiDomain}/api/Employee/FindAllByEmployeeBirthday?companyID={companyID}¤tPage={currentPage}&searchText={searchText}&itemsPerPage={itemsPerPage}&isDesc={isDesc}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得員工發生錯誤"))); } }
public Jsend DeleteCompanyByID(int id) { try { _uow.CompanyTRepository.Delete(id); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("Delete data occured error.")); } return(JsendResult.Success()); }
public ActionResult GetProductListByID(int page, int?searchText, bool isDesc = false, string sortBy = "ProductID") { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <ProductModel> > >( $"{apiDomain}/api/Product/GetProductListByID?current={page}&itemsPerPages=10&&searchText={searchText}&isDesc={isDesc}&&sortBy={sortBy}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得產品發生錯誤"))); } }
public ActionResult GetEmployeeListByName(int page, string searchText, bool isDesc = false, string sortBy = "EmployeeID") { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <EmployeeModel> > >( $"{apiDomain}/api/Employee/GetEmployeeListByName?current={page}&itemsPerPages=10&&searchText={searchText}&isDesc={isDesc}&&sortBy={sortBy}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得員工發生錯誤"))); } }
public ActionResult GetCompanyListByName(int page, int itemsPerPage, string searchText, bool isDesc = false) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <OneToManyMap <CompanyModel> > >( $"{apiDomain}/api/Company/GetCompanyListByName?current={page}&itemsPerPage={itemsPerPage}&searchText={searchText}&isDesc={isDesc}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("GetCompanyList occured error"))); } }
public ActionResult GetEmployeeByName(string name) { try { var result = RequestHelper.MakeGetWebRequest <Jsend <EmployeeModel> >( $"{apiDomain}/api/Employee/GetEmployeeByName?name={name}"); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("取得員工發生錯誤"))); } }
public ActionResult FindAllRoles(int currentPage, int itemsPerPage, bool isDesc = false) { Jsend <OneToManyMap <AppRole> > result = null; try { result = _roleManager.FindAllRoles(currentPage, itemsPerPage, isDesc); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("FindAllRoles occured error"))); }
public ActionResult DeleteEmployeeByID(int id) { try { var data = RequestHelper.MakePostWebRequest <EmployeeModel, Jsend <EmployeeModel> >( $"{apiDomain}/api/Employee", new EmployeeModel { EmployeeID = id }, "DELETE"); return(Jsend(data)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("刪除員工發生錯誤"))); } }
public ActionResult DeleteCompanyByID(int id) { try { var data = RequestHelper.MakePostWebRequest <CompanyModel, Jsend <CompanyModel> >( $"{apiDomain}/api/Company", new CompanyModel { CompanyID = id }, "DELETE"); return(Jsend(data)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("刪除公司發生錯誤"))); } }
public ActionResult AddRolesToUser(int userId, List <int> roleIds) { try { _userManager.AddMultipleRoles(new AppMember { Id = userId }, roleIds); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("AddRoleToUser occured error"))); }
public Jsend <OneToManyMap <ProductTAndCompanyT> > FindAllByProductPrice(int?productPrice, int currentPage, int itemsPerPage, bool isDesc = false) { OneToManyMap <ProductTAndCompanyT> result = null; try { result = _uow.ProductTRepository.FindAllByProductPrice(productPrice, currentPage, itemsPerPage, isDesc); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <OneToManyMap <ProductTAndCompanyT> > .Error("Queay data occured error")); } return(JsendResult <OneToManyMap <ProductTAndCompanyT> > .Success(result)); }
public Jsend <OneToManyMap <EmployeeTAndCompanyT> > FindAllByEmployeeBirthday(string companyID, string searchText, int currentPage, int itemsPerPage, bool isDesc = false) { OneToManyMap <EmployeeTAndCompanyT> result = null; try { result = _uow.EmployeeTRepository.FindAllByEmployeeBirthday(companyID, searchText, currentPage, itemsPerPage, isDesc); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <OneToManyMap <EmployeeTAndCompanyT> > .Error("Queay data occured error")); } return(JsendResult <OneToManyMap <EmployeeTAndCompanyT> > .Success(result)); }
public Jsend <OneToManyMap <EmployeeT, CompanyT> > FindCompanyListByID(int id, int current, int itemsPerPages, bool isDesc) { OneToManyMap <EmployeeT, CompanyT> result = null; try { result = _uow.EmployeeTRepository.FindAllByCompanyID(id, current, itemsPerPages, isDesc); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <OneToManyMap <EmployeeT, CompanyT> > .Error("Queay data occured error")); } return(JsendResult <OneToManyMap <EmployeeT, CompanyT> > .Success(result)); }
public Jsend <EmployeeT> FindEmployeeByName(string name) { EmployeeT result = null; try { result = _uow.EmployeeTRepository.FindByName(name); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <EmployeeT> .Error("FindEmployeeByName() occured error")); } return(JsendResult <EmployeeT> .Success(result)); }
public Jsend <EmployeeT> FindEmployeeByID(int id) { EmployeeT result = null; try { result = _uow.EmployeeTRepository.FindByID(id); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <EmployeeT> .Error("")); } return(JsendResult <EmployeeT> .Success(result)); }
public ActionResult DeleteRoleByID(int id) { try { _roleManager.DeleteAsync(new AppRole { Id = id, }); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("DeleteRole occured error"))); }
public ActionResult AddRoleToUser(int userId, string roleName) { try { _userManager.AddToRoleAsync(new AppMember { Id = userId }, roleName); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("AddRoleToUser occured error"))); }
public ActionResult DeleteProductByID(int id) { try { var data = RequestHelper.MakePostWebRequest <ProductModel, Jsend <ProductModel> >( $"{apiDomain}/api/Product", new ProductModel { ProductID = id }, "DELETE"); return(Jsend(data)); } catch (WebException ex) { Console.WriteLine(ex); return(Jsend(JsendResult.Error("刪除產品發生錯誤"))); } }
public Jsend <OneToManyMap <CompanyT> > FindCompanyListByName(int current, int itemsPerPage, bool isDesc, string searchText) { OneToManyMap <CompanyT> result = null; try { result = _uow.CompanyTRepository.FindAllByName(current, itemsPerPage, searchText, isDesc); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <OneToManyMap <CompanyT> > .Error("Queay data occured error")); } return(JsendResult <OneToManyMap <CompanyT> > .Success(result)); }
public ActionResult AddRole(string roleName) { try { _roleManager.CreateAsync(new AppRole { Name = roleName }); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("AddRole occured error"))); }
//public Jsend<OneToManyMap<ProductT>> FindAll(int currentPage, int itemsPerPages, bool isDesc = false) //{ // OneToManyMap<ProductT> result = null; // try // { // result = _uow.ProductTRepository.FindAll(currentPage, itemsPerPages, isDesc); // _uow.Commit(); // } // catch (SqlException ex) // { // _logger.Error(ex); // return JsendResult<OneToManyMap<ProductT>>.Error(""); // } // return JsendResult<OneToManyMap<ProductT>>.Success(result); //} public Jsend <ProductT> FindProductByID(int id) { ProductT result = null; try { result = _uow.ProductTRepository.FindByID(id); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <ProductT> .Error("")); } return(JsendResult <ProductT> .Success(result)); }
public Jsend <List <ValidationFailure> > AddCompany(CompanyModel data) { if (data == null) { return(JsendResult <List <ValidationFailure> > .Error("Company data can't be null")); } var checkNameUnique = _uow.CompanyTRepository.FindByName(data.CompanyName); if (checkNameUnique != null) { return(JsendResult <List <ValidationFailure> > .Error("CompanyName has already had")); } var validator = new CompanyValidator(); ValidationResult validateResult = validator.Validate(data); if (validateResult.IsValid) { try { _uow.CompanyTRepository.Add( new CompanyT { CompanyName = data.CompanyName, CompanyCode = data.CompanyCode, TaxID = data.TaxID, Phone = data.Phone, Owner = data.Owner, WebsiteURL = data.WebsiteURL, Address = data.Address }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <List <ValidationFailure> > .Error("Insert data error")); } return(JsendResult <List <ValidationFailure> > .Success()); } List <ValidationFailure> failures = validateResult.Errors.ToList(); return(JsendResult <List <ValidationFailure> > .Fail(failures)); }