public Jsend <List <ValidationFailure> > AddProduct(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.Add(new ProductT { CompanyID = data.CompanyID, ProductName = data.ProductName, ProductType = data.ProductType, Price = data.Price, Unit = data.Unit }); _uow.Commit(); return(JsendResult <List <ValidationFailure> > .Success()); } catch (SqlException ex) { _logger.Error(ex); return(JsendResult <List <ValidationFailure> > .Error("Insert Product occured error")); } } List <ValidationFailure> failures = validateResult.Errors.ToList(); return(JsendResult <List <ValidationFailure> > .Fail(failures)); }
public Jsend <List <ValidationFailure> > InsertUpdateEmployee(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 { var result = _uow.EmployeeTRepository.FindByID(data.EmployeeID); if (result == null) { _uow.EmployeeTRepository.Add(new EmployeeT { EmployeeName = data.EmployeeName, EmployeePosition = data.EmployeePosition, EmployeePhone = data.EmployeePhone, Email = data.Email, BirthdayDate = data.BirthdayDate, SignInDate = data.SignInDate, ResignedDate = data.ResignedDate, IsResigned = data.IsResigned, CompanyID = data.CompanyID }); } else { _uow.EmployeeTRepository.Update(new EmployeeT { EmployeeID = data.EmployeeID, EmployeeName = data.EmployeeName, EmployeePosition = data.EmployeePosition, EmployeePhone = data.EmployeePhone, 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> > 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)); }
/// <summary> /// Returns the roles for a given TUser and Pagination /// </summary> /// <param name="user"></param> /// <returns></returns> public Jsend <OneToManyMap <IdentityRole> > GetNotInRolesByUser(TUser user, int currentPage, int itemsPerPages, bool isDesc = false) { if (user == null) { throw new ArgumentNullException("user"); } OneToManyMap <IdentityRole> roles = userRolesTable.FindNotInRolesByUser(user.Id, currentPage, itemsPerPages, isDesc); return(JsendResult <OneToManyMap <IdentityRole> > .Success(roles)); }
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 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 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<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 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 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 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 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 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 <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 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 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 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 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 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 <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 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 <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)); }