public bool updateProductById(int id, ProductsAdModel productAd) { try { var product = this.GetProductById(id); if (product != null) { product.code = productAd.code; product.name = productAd.name; product.description = productAd.description; product.image = productAd.image; product.more_images = productAd.more_images; product.detail = productAd.detail; product.keywords = productAd.keywords; product.includeVAT = productAd.includeVAT; product.price = productAd.price; product.price_promotion = productAd.price_promotion; product.menu_id = JsonConvert.SerializeObject(productAd.menu_id); product.provider_id = int.Parse(productAd.provider_id.ToString()); product.start_time = productAd.start_time; product.total_product = productAd.total_product; db.Entry(product).State = EntityState.Modified; db.SaveChanges(); return(true); } return(false); } catch (Exception e) { } return(false); }
public bool updateRoleById(int id, role updateRole) { var currentRole = this.getRoleById(id); if (currentRole != null) { currentRole.name = updateRole.name; db.Entry(currentRole).State = EntityState.Modified; db.SaveChanges(); return(true); } return(false); }
public bool updateById(int id, AdminsModel updateAdmin) { try { var currentAdmin = this.getAdminById(id); if (currentAdmin != null) { currentAdmin.full_name = updateAdmin.full_name; currentAdmin.email = updateAdmin.email; //currentAdmin.password = updateAdmin.password; currentAdmin.gender = updateAdmin.gender; currentAdmin.date_of_birth = updateAdmin.date_of_birth; currentAdmin.phone_number = updateAdmin.phone_number; currentAdmin.address = updateAdmin.address; currentAdmin.role = int.Parse(updateAdmin.role.ToString()); db.Entry(currentAdmin).State = EntityState.Modified; db.SaveChanges(); return(true); } return(false); }catch (Exception e) { throw e; } }
public bool updateMenuById(int id, menu updateMenu) { var currentMenu = this.getMenuById(id); if (currentMenu != null) { currentMenu.name = updateMenu.name; currentMenu.parent_id = updateMenu.parent_id; currentMenu.link = updateMenu.link; currentMenu.order = updateMenu.order; db.Entry(currentMenu).State = EntityState.Modified; db.SaveChanges(); return(true); } return(false); }
public bool updateUserById(int id, UsersAdModel updateUser) { try { var currentUser = this.getUserById(id); if (currentUser != null) { currentUser.display_name = updateUser.display_name; currentUser.gender = updateUser.gender; currentUser.date_of_birth = updateUser.date_of_birth; currentUser.phone_number = updateUser.phone_number; currentUser.address = updateUser.address; db.Entry(currentUser).State = System.Data.Entity.EntityState.Modified; db.SaveChanges(); return(true); } return(false); }catch (Exception e) { return(false); } }