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 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 <OneToManyMap <EmployeeTAndCompanyT> > FindAllByEmployeePhone(string companyID, string searchText, int currentPage, int itemsPerPage, bool isDesc = false) { OneToManyMap <EmployeeTAndCompanyT> result = null; try { result = _uow.EmployeeTRepository.FindAllByEmployeePhone(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 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 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 <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 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 <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)); }
public ActionResult GetNotInRolesByUser(int id, int currentPage, int itemsPerPage, bool isDesc = false) { Jsend <OneToManyMap <IdentityRole> > result = null; try { result = _userManager.GetNotInRolesByUser(new AppMember { Id = id }, currentPage, itemsPerPage, isDesc); return(Jsend(result)); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("GetRolesByUser occured error"))); }
public Jsend DeleteEmployee(int id) { try { _uow.EmployeeTRepository.Delete(new EmployeeT { EmployeeID = id }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("DeleteEmployee() Delete data occured error.")); } return(JsendResult.Success()); }
public Jsend <CompanyT> FindCompanyByID(int id) { CompanyT result = null; try { result = _uow.CompanyTRepository.FindByID(id); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <CompanyT> .Error("Queay data occured error")); } return(JsendResult <CompanyT> .Success(result)); }
public ActionResult UpdateRole(int roleId, string roleName) { try { _roleManager.UpdateAsync(new AppRole { Id = roleId, Name = roleName }); return(Jsend(JsendResult.Success())); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("UpdateRole occured error"))); }
public Jsend DeleteProduct(int id) { try { _uow.ProductTRepository.Delete(new ProductT { ProductID = id }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("DeleteProduct() Delete data occured error.")); } return(JsendResult.Success()); }
public ActionResult GetUsersByTypeAndLoginState(int memberType, bool isLogin, int currentPage, int itemsPerPage, bool isDesc) { try { var result = _userManager.GetUsersByTypeAndLoginState(memberType, isLogin, currentPage, itemsPerPage, isDesc); Jsend <OneToManyMap <UserViewModel> > jsendUserViewModel = new Jsend <OneToManyMap <UserViewModel> >() { data = new OneToManyMap <UserViewModel> { List = new List <UserViewModel>() } }; List <UserViewModel> mapData = new List <UserViewModel>(); foreach (var user in result.data.List) { mapData.Add(new UserViewModel { Id = user.Id, Email = user.Email, UserName = user.UserName, PhoneNumber = user.PhoneNumber, MemberType = user.MemberType, IsLoggined = user.IsLogined }); } jsendUserViewModel.status = result.status; jsendUserViewModel.message = result.message; jsendUserViewModel.code = result.code; if (result.data != null) { jsendUserViewModel.data.List = mapData; jsendUserViewModel.data.TotalCount = mapData.Count; } return(Jsend(jsendUserViewModel)); } catch (WebException ex) { Console.WriteLine(ex); } return(Jsend(JsendResult.Error("GetUsersByTypeAndLoginState occured error"))); }
public Jsend <List <ValidationFailure> > UpdateCompany(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 { _uow.CompanyTRepository.Update( new CompanyT { CompanyID = data.CompanyID, CompanyName = data.CompanyName, CompanyCode = data.CompanyCode, TaxID = data.TaxID, Phone = data.Phone, Owner = data.Owner, Address = data.Address, WebsiteURL = data.WebsiteURL }); _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 Jsend DeleteCompany(CompanyModel data) { if (data == null) { return(JsendResult.Error("Company data can't be null")); } try { _uow.CompanyTRepository.Delete(new CompanyT { CompanyID = data.CompanyID }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("Delete data occured error.")); } return(JsendResult.Success()); }
public Jsend <CompanyT> FindComapnyByTaxID(string id) { if (string.IsNullOrWhiteSpace(id)) { return(JsendResult <CompanyT> .Error("name can't be null")); } CompanyT result = null; try { result = _uow.CompanyTRepository.FindByTaxID(id); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <CompanyT> .Error("Queay data occured error")); } return(JsendResult <CompanyT> .Success(result)); }
public Jsend DeleteEmployee(EmployeeModel data) { if (data == null) { return(JsendResult.Error("Employee data can't be null")); } try { _uow.EmployeeTRepository.Delete(new EmployeeT { EmployeeID = data.EmployeeID }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("DeleteEmployee() Delete data occured error.")); } return(JsendResult.Success()); }
public Jsend DeleteProduct(ProductModel data) { if (data == null) { return(JsendResult.Error("Product data can't be null")); } try { _uow.ProductTRepository.Delete(new ProductT { ProductID = data.ProductID }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult.Error("DeleteProduct() Delete data occured error.")); } return(JsendResult.Success()); }
public Jsend <List <ValidationFailure> > UpdateEmployee(EmployeeModel data) { if (data == null) { return(JsendResult <List <ValidationFailure> > .Error("Employee data can't be null")); } var validator = new EmployeeValidator(); ValidationResult validateResult = validator.Validate(data); if (validateResult.IsValid) { try { _uow.EmployeeTRepository.Update(new EmployeeT { EmployeeID = data.EmployeeID, EmployeeName = data.EmployeeName, EmployeePhone = data.EmployeePhone, EmployeePosition = data.EmployeePosition, Email = data.Email, BirthdayDate = data.BirthdayDate, SignInDate = data.SignInDate, ResignedDate = data.ResignedDate, IsResigned = data.IsResigned, Salary = data.Salary, }); _uow.Commit(); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <List <ValidationFailure> > .Error("InsertUpdateEmployee() InsertUpdate data occured error")); } return(JsendResult <List <ValidationFailure> > .Success()); } List <ValidationFailure> failures = validateResult.Errors.ToList(); return(JsendResult <List <ValidationFailure> > .Fail(failures)); }
public Jsend <List <ValidationFailure> > UpdateProduct(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 { _uow.ProductTRepository.Update(new ProductT { ProductID = data.ProductID, ProductName = data.ProductName, ProductType = data.ProductType, Price = data.Price, Unit = data.Unit, EditedDate = DateTime.UtcNow }); _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 Jsend <OneToManyMap <TUser> > FindAllUsers(int currentPage, int itemsPerPages, bool isDesc = false) { OneToManyMap <TUser> result = userTable.FindAllUsers(currentPage, itemsPerPages, isDesc); return(JsendResult <OneToManyMap <TUser> > .Success(result)); }
public Jsend <OneToManyMap <TUser> > GetUsersByTypeAndLoginState(int memberType, bool isLogined, int currentPage, int itemsPerPage, bool isDesc) { OneToManyMap <TUser> result = userTable.GetUsersByTypeAndLoginState(memberType, isLogined, currentPage, itemsPerPage, isDesc); return(JsendResult <OneToManyMap <TUser> > .Success(result)); }