public int addProduct(string nameProduct, string infoProduct, long categoryId, long brandId, long userId, bool sessionAuth) { try { if (checkPermission.checkAuth(sessionAuth)) { DTO_Product dto_product = new DTO_Product(); dto_product.ProductId = dal_products.increment(); dto_product.NameProduct = nameProduct; dto_product.InfoProduct = infoProduct; dto_product.CategoryId = categoryId; dto_product.BrandId = brandId; dto_product.Point = 0; dto_product.UserId = userId; if (dal_products.addProduct(dto_product)) { return(200); } else { return(400); } } else { return(403); } } catch { return(400); } }
public int editAccount(long userId, string userName, string id, string pass, string address, string avt, long phone, bool sessionAuth) { DTO_Account dto_account = new DTO_Account(); dto_account.UserId = userId; dto_account.UserName = userName; dto_account.Id = id; dto_account.Pass = pass; dto_account.Address = address; dto_account.Phone = phone; try { if (checkPermission.checkAuth(sessionAuth)) { if (checkPermission.isAdmin(userId) /*|| checkRoleAccount.checkRole(userId)*/) { return(dal_account.editAccount(dto_account) == true ? 200 : 400); } else { return(403); } } else { return(403); } } catch { return(400); } }